Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86604 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33772 invoked from network); 12 Jun 2015 00:36:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jun 2015 00:36:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=are.you.winning@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=are.you.winning@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.176 as permitted sender) X-PHP-List-Original-Sender: are.you.winning@gmail.com X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:37098] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/F5-31453-D892A755 for ; Thu, 11 Jun 2015 20:36:29 -0400 Received: by wifx6 with SMTP id x6so1875745wif.0 for ; Thu, 11 Jun 2015 17:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=jLUeygzeQKWHuZK8oxK3OvwkB9MNr0Nk5RDzRDA43XU=; b=fIGpZ3VBfvrLzjvucGIk5cCLM9FiiMlGAGgx7E4cZK5YcueqkFAUUhvEnrPZXyxBM+ FJNWfdeYSLhaXyHj/BChzlrsmDv6VXBm1ZJt/9dcOT7jW6uMrJeVidXkQRVLuCH7Lgep wcbfOQ2no35nma9qc5qDazgugog+M/rd9TEjbD02xYnrtXw3IXm+Th8vsoGJqKlXTYGq qu90BhpZnAIeH/MD/yDCWABMiA1Ji4oT8h5r3XWTV4lLyRhmDxqDb8F2/zwqMSZE63oD fk4odm89UsH2Rq5jDzUlTrtPLSKXGYYQ305m7AAdPSyVwh2H4cl4CT7qu7Z2mzZ4UQ3k bdiw== MIME-Version: 1.0 X-Received: by 10.180.106.97 with SMTP id gt1mr1504817wib.37.1434069386398; Thu, 11 Jun 2015 17:36:26 -0700 (PDT) Sender: are.you.winning@gmail.com Received: by 10.181.23.193 with HTTP; Thu, 11 Jun 2015 17:36:26 -0700 (PDT) In-Reply-To: <557A1B52.1050501@gmail.com> References: <5576051A.3040800@gmx.de> <55760771.6020802@gmail.com> <778F345F9918474AB8CAAB03082ECBF7@pc1> <5577DEE4.8030205@gmail.com> <55794DE2.2080602@gmail.com> <557A1B52.1050501@gmail.com> Date: Fri, 12 Jun 2015 01:36:26 +0100 X-Google-Sender-Auth: Uh6qafwCQKfjkpW5JuzBjfwGspI Message-ID: To: Rowan Collins Cc: PHP Internals List Content-Type: multipart/alternative; boundary=f46d044280665c12930518474c6b Subject: Re: [PHP-DEV] Array dereferencing of scalars From: cw@daverandom.com (Chris Wright) --f46d044280665c12930518474c6b Content-Type: text/plain; charset=UTF-8 On 12 June 2015 at 00:35, Rowan Collins wrote: > On 11/06/2015 21:22, Chris Wright wrote: > >> I'm inclined to agree that we should have consistency here, and that the >> current behaviour in a function context is the correct one. A couple of >> (IMO) good arguments for this: >> >> - The function behaviour gives a more explanatory and useful error message >> - This is definitely a programming error, there is no valid reason to use >> NULL as a variable name in this manner. It amounts to what many/most other >> languages would consider to be a "null pointer exception" or equivalent, >> and the more useful error message may help track down the error quicker >> (one might look for a case where the empty string was assigned, instead of >> looking for a case where it may be NULL). >> > > Well, if you were to model it precisely on the function case, the > *consistent* behaviour would be to error on any non-string value (e.g. $v = > 42; $$v;) but not a string which is an illegal variable name ($v = '42'; > $v(); just complains that function 42 doesn't exist, not that it never > could). > > A more useful approach would perhaps be to look at what should be a valid > function name, and what should be a valid variable name, and throw an error > if dynamic access is used to by-pass either restriction. > +1 If anything is to be done, then this should be it - properly abstract the underlying structures so that the lexical/conventional limitations on symbol naming are also imposed by mechanisms that let userland directly manipulate the names of symbols (define(), class_alias() etc). > > For instance, this doesn't currently complain about the fact that @ is > clearly nonsensical as either a function or a variable: > > $foo = '@'; > var_dump($$foo); > $foo(); > > And nor does the empty string, which seems no less obvious a bug than a > NULL: > > $foo = ''; > var_dump($$foo); > $foo(); > > > > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --f46d044280665c12930518474c6b--