Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69176 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2948 invoked from network); 18 Sep 2013 05:19:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2013 05:19:41 -0000 Authentication-Results: pb1.pair.com header.from=leverton@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leverton@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.173 as permitted sender) X-PHP-List-Original-Sender: leverton@gmail.com X-Host-Fingerprint: 209.85.214.173 mail-ob0-f173.google.com Received: from [209.85.214.173] ([209.85.214.173:57402] helo=mail-ob0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/71-25618-CE739325 for ; Wed, 18 Sep 2013 01:19:41 -0400 Received: by mail-ob0-f173.google.com with SMTP id vb8so6957511obc.32 for ; Tue, 17 Sep 2013 22:19:37 -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=BIl0lZBfoSV6c+vwenX5NYwpl4ESAoS/cbNjYyi8aw0=; b=hF5LplUKzDOajF/YL2FuiNz25PE9tO3mg9N1R27tK2L8MdNEGPz5wb9Q2uzrtvAo+w wm55GNNEMEeDGEqX083/k97hm2sATowdQBbjrOV62CA4h5O6RNGPd0vcqEJVyQHp36mP t63+NZ1fPwKquPmk14gXk0ezFG5RoBbS/NsHhPI74clE3zlLxZCB7kTqJvzbuT4okEM3 8LMCxTyoF32vTxPLrnOJmnhxnWM8eF0HFNx8Mls3rV83Sjm8b3RYd4xBHZN2lmSrAwFw XazPBzpyUZuc4m14JW4fRY7yI+CZGzMTxqf6vK0pnPe90ybDKtD08MVLXm7JAcwbQj1f eTdg== MIME-Version: 1.0 X-Received: by 10.60.51.196 with SMTP id m4mr32788751oeo.1.1379481577744; Tue, 17 Sep 2013 22:19:37 -0700 (PDT) Received: by 10.182.133.34 with HTTP; Tue, 17 Sep 2013 22:19:37 -0700 (PDT) In-Reply-To: References: Date: Wed, 18 Sep 2013 00:19:37 -0500 Message-ID: To: Stuart Langley Cc: Bob Weinand , Developers PHP Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Keywords as identifiers From: leverton@gmail.com (Matthew Leverton) On Tue, Sep 17, 2013 at 7:50 PM, Stuart Langley wrote: > To be honest, looking at the example in the RFC, being able to define a > member function 'new' on a class that completely changes the semantics of > the new operator is a great example of why you would not want this feature. > It doesn't change anything because $foo->new() has no intrinsic meaning in PHP. And I don't think the argument "the programmer might do something stupid" ever holds much weight as a no vote against anything. If somebody wants to create a confusing misnomer, he doesn't need this proposed feature to do so. But I agree that the RFC is missing any real-world examples of why it might be useful, and that any new language feature should have real-world benefits. Hopefully some more compelling reasons will be added to the RFC. Here's something that I've personally done with much shame: class Where { private function _or($lhs, $op = null, $rhs = null) { } public function __call($func_name, $args) { if ($func_name == 'or') return call_user_func_array([$this, '_or'], $args); } } $query->where('foo', '=', 1)->or('bar', '=', 2); Imagine that $query->where() returns a Where object. I really want an "or" method because it make things concise & readable, but this is not allowed. So I override the __call method to add such functionality, which adds useless overhead. There are a few keywords, such as list and unset, that I often wish I could use in PHP. So in terms of readability, I think any sane programmer would use this proposed functionality for good... -- Matthew Leverton