Re: Make primitive type names reserved words (Was: Re: [PHP-DEV] [RFC] 5.4 features for vote (long))
| From: | Matthew Weier O'Phinney | Date: | Tue, 12 Jul 2011 14:18:13 +0000 |
| Subject: | Re: Make primitive type names reserved words (Was: Re: [PHP-DEV] [RFC] 5.4 features for vote (long)) | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53919@lists.php.net to get a copy of this message | ||
On 2011-07-12, Johannes Schlüter <johannes@schlueters.de> wrote:
> On Sun, 2011-07-10 at 19:41 +0200, Nikita Popov wrote:
> > E.g. Writing
> >
> > class Evaluator {
> > public function eval() {
> >
> > }
> > }
> >
> > Does in no way create an ambiguity with the eval language construct
> > PHP implements.
>
> For a method this is correct. But for a normal function this is
> different:
>
> <?php
> function eval() {
> }
> eval(); // will call the language construct
> ?>
But what about this?
namespace Foo
{
function eval($name)
{
echo $name;
}
eval('matthew');
}
The manual doesn't really differentiate between language constructs and
functions, and as such, I can see somebody reading the namespace section
of the manual and feeling this should be valid -- but currently, it
results in a parse error.
It seems to me we need a context-sensitive lexer.
> And i consider it "strange" to allow different names for functions and
> methods. And yes I'm aware that
> $eval = 'eval'; $eval();
> would call the function.
>
> I fear consistency issues.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc