Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108310 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68981 invoked from network); 29 Jan 2020 10:45:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jan 2020 10:45:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A11C6180511 for ; Wed, 29 Jan 2020 00:55:34 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 29 Jan 2020 00:55:33 -0800 (PST) Received: by mail-qt1-f177.google.com with SMTP id l19so7073201qtq.8 for ; Wed, 29 Jan 2020 00:55:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=mD+RfMNdEhPJsahJBDtZ1hYUrRU30z1u02/qOeEJvco=; b=Qp90qppundV6GYKnwbQ+uueFoEZnNvPsAy6POU3itxFv/FKJ640gBjVOcsKmywzlXe Do1X3q8lIzceIgsLFZUddfBRRBczO7/bkEGCPBTZo5rCI4sk5pBER356QllU+qcrEKRN tyuj8RUQgy0A9UUhs6ZbbPjtoeWyvXkE7Dmq1cm8XPA2iREEGg9YKQjqaJlUyxMvAiU3 BA9J+u+bN1cd1KZNIS9vBSeYBZ7AGY8AI8doI68wJIVYTpEZxuu2ZmodDw40hkGkuWsq oVMUH+EtZdcvOI3Edil4Gy5kmYBhZhoUD7+gWUBop85YxJf9rVu/MwTKT5gettRu8QMy Ez3A== X-Gm-Message-State: APjAAAXQONnYYuZISUFl26gSW3Zu7ewccBPo/2tchdC2NSV0siCvfYhY fpKlbzgBNTMrhvWg9cGrAWI4ZlLG8vC724vylUM= X-Google-Smtp-Source: APXvYqxe3rSHNymRAV81VwyTDtCMe8DEf1SL/gXG/7856XVrcn+/v+W4t0+8rRZ0wQe4+JOmUYGnUrPWhweEcIOnMEs= X-Received: by 2002:ac8:710a:: with SMTP id z10mr26354540qto.181.1580288130650; Wed, 29 Jan 2020 00:55:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Reply-To: bishop@php.net Date: Wed, 29 Jan 2020 03:55:22 -0500 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="000000000000ab9720059d43807a" Subject: Re: [PHP-DEV] [VOTE] declare(function_and_const_lookup='global') From: bishop@php.net (Bishop Bettini) --000000000000ab9720059d43807a Content-Type: text/plain; charset="UTF-8" On Tue, Jan 28, 2020 at 9:22 PM tyson andre wrote: > > I've opened the vote on https://wiki.php.net/rfc/use_global_elements > after weighing the pros and cons of discussed alternative approaches. > Yesterday, I've finished the last set of updates I announced I would do > based on RFC feedback. > > (that update was to require the statement 'use function ...'/'use const > ...' before declaring that function/const > outside the global namespace, > if declare(function_and_const_lookup='global') is opted into) > > Voting closes on 2020-02-11. > Notwithstanding the excellent work done in the PR, I lean toward a No vote. Suppose I'm presented with this diff (and only this diff): $a = array_diff($x, $y); + if (count($a)) die('Unexpected differences'); Where does count come from? I can't tell from this diff. It could be local to this namespace, or it could be global. In the current implementation, I have to scroll to the top of the file, check for what namespace I am in, and what use are made. In the proposed implementation, I have also to check the top of the file, but now its for "declare(function_and_cost_lookup='global')" and the presence (or not) of "use function count". It's not clear to me this is an improvement over status quo. Indeed, I worry that implementing the proposal may increase overall cognitive burden for PHP developers. Today, any developer can look at any file or snippet in any code base, anywhere in the world, and know that using an unqualified name follows a single, language-defined algorithm. Were this proposal accepted, developers no longer have that guarantee. The code might be using the original algorithm, or it might be using the new algorithm. The only way to know is to check for and remember the state based on the presence of -- and value of -- this new declaration. Resolving ambiguities has a compute cost and a cognitive cost. While the proposal improves the compute cost, I'm not sure the same can be said of the cognitive cost. So I am leaning toward a No vote. What do you think? --000000000000ab9720059d43807a--