Re: $obj->attr::method() is not allowed
| From: | Ivan Enderlin @ Hoa | Date: | Mon, 03 Sep 2012 15:20:56 +0000 |
| Subject: | Re: $obj->attr::method() is not allowed | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62748@lists.php.net to get a copy of this message | ||
On 03/09/12 17:18, Andrew Faulds wrote:
On 03/09/12 15:51, Ivan Enderlin @ Hoa wrote:PHP has no AST? Why? For historical reasons? -- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/I would like to know why? Is it a compiler related issue or just an omission? Would it be interesting to fix it?There are plenty of examples of this. One from my code: Can't do this:self::$views[$path]();But I *can* do this:$x = self::$views[$path]; $x();This is because PHP has a very unusual (and IMO bad) system of type-checking at parse-time, by only allowing some specific (although quite varied) types of variable access, and combinations of these. If nikic's idea to rewrite the parser to use an AST is done, I imagine this could be fixed. We could also add extra rules, but I think fixing the general issue is more important, since it's like plugging two holes in a barrel full of water that's just had a machine gun fired at it. Absolutely.