Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69105 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80616 invoked from network); 12 Sep 2013 20:55:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Sep 2013 20:55:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.48 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.48 mail-oa0-f48.google.com Received: from [209.85.219.48] ([209.85.219.48:40287] helo=mail-oa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/D0-09838-A5A22325 for ; Thu, 12 Sep 2013 16:55:54 -0400 Received: by mail-oa0-f48.google.com with SMTP id o17so370142oag.21 for ; Thu, 12 Sep 2013 13:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=PPc0XGFNIHfYvlbHO0F1r7XfQijJ9Yr4aG5XSkWPkzw=; b=SHy1yKBuTK3eXWRXGRc3h9aGA2y36Jk7cy2ytzjb2KT1iSgieri2k3SFvD9DNlaqGI S1IsZupMxnwBYKMLwFv+0HgDTFguL3x8yReaHyRiBn7yuUB5ONZzP0B7ADQX2uDNXNiJ q2tzxGRLM9npMDEo+6LynX7LbSjRjEJa+FXJVk/mvxR0tr5YrOzSa3VnnTYeNxkn08U6 HlcB+p+M83SdGF6KftTgXS7cFjZHXE9ZRDhrgbMO2j/I6CFohUUBYCsJ8x8kzJhBu4lb ZGepR8BAOTu6P1fQGmeQntH64SzSKhb9v2twxPdoWch9kwOkYO0fb9NcFqsM8VME3YOJ Hd9g== MIME-Version: 1.0 X-Received: by 10.182.101.165 with SMTP id fh5mr4055312obb.58.1379019351364; Thu, 12 Sep 2013 13:55:51 -0700 (PDT) Received: by 10.182.98.8 with HTTP; Thu, 12 Sep 2013 13:55:51 -0700 (PDT) In-Reply-To: <1379018669.12435.1710.camel@guybrush> References: <1379018669.12435.1710.camel@guybrush> Date: Thu, 12 Sep 2013 22:55:51 +0200 Message-ID: To: =?ISO-8859-1?Q?Johannes_Schl=FCter?= Cc: Bob Weinand , Developers List PHP Mailing Content-Type: multipart/alternative; boundary=e89a8f6436d29399e604e635f6ad Subject: Re: [PHP-DEV] Support for keywords where possible From: nikita.ppv@gmail.com (Nikita Popov) --e89a8f6436d29399e604e635f6ad Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, Sep 12, 2013 at 10:44 PM, Johannes Schl=FCter wrote: > I often stumbled over the annoyance of this limitation and I know many > users want it, I'm not convinced about adding it, though. > > One reason is the "where (easily) possible" part. Right now we have a > simple rule "keywords can't be reused". This is being changed to "this > and that keyword can be used her and there." I don't believe this is > good. > > Secondly I'm among the people who read tons of "bad" code and I'm sure > people will abuse this and we will find code like this: > > namespace network; > function if($which) { > // ... some logic ... > return "eth0"; > } > // ... somewhere else in the namespace ... > if($condition); > ?> > > This can hide subtile typos or coding errors. Also look at currently > valid PHP code like this: > > function while() {} > $condition =3D true; > while ($condition) > ?> > > and while reading this mind that an ; in front of an ?> is optional, so > will this call a function and exit or be stuck in an infinite loop? > > I'm sure one could construct other such cases. > > I'm more open about allowing such identifiers as method names only, as > those are prefixed in some way ($object-> or someClass:: ) but even > there I tend to consider the consistency between function and method > names more important than this flexibility. > I tend to agree with Johannes. Supporting different sets of keywords in different locations is pretty confusing. Imho we should add this kind of support only in places where a) we can support all keywords and b) it is unlikely that supporting keywords there will cause issues in the future. One such case are method names. Methods with keyword names are currently callable using $foo->array(), because the identifier after T_OBJECT_OPERATOR is always a T_STRING. But while you can call them, it is currently not possible to define them as real methods. Instead you need to forward them via __call magic, which is rather ugly. Internal classes on the other hand can and do define methods with reserved-keyword names. E.g. there is a Generator::throw() method. Nikita --e89a8f6436d29399e604e635f6ad--