Re: Re: internals Digest 22 Feb 2012 22:13:24 -0000 Issue 2561

From: Date: Fri, 24 Feb 2012 21:36:42 +0000
Subject: Re: Re: internals Digest 22 Feb 2012 22:13:24 -0000 Issue 2561
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-58027@lists.php.net to get a copy of this message
On 24/02/12 17:46, Dmitri Snytkine wrote: > In order to intoduce the enum into php, 'enum' will have to be a keyword like > 'class', 'interface', etc. > > Just a thought, but could there be a problem with using the new keyword 'enum' in > php. I don't think it's currently a reserved word, so it could potentially cause problems > if a script uses the word enum for existing variable name or a function or a class name? > > > Dmitri Snytkine I think it would be _possible_ to handle it in a completely backwards compatible way, as no valid usage would conflict with new one, and context could disambiguate them. A variable called enum would be $enum, so no problem there, but currently you could have enum in these contexts: function enum (...) { class enum { interface enum { and the new usage would be like: enum <name> { Also, you could have defined a constant called enum, but makes no sense to use it at the beginning of a sentence. That said, it would be hard to support such usages compared to the given gain, so I suppose it would just produce a parser error about T_ENUM in the above scenarios.

« previous php.internals (#58027) next »