Re: RFC: C-sharp style property get/set syntax for PHP
| From: | president at basnetworks dot net | Date: | Mon, 06 Dec 2010 02:11:08 +0000 |
| Subject: | Re: RFC: C-sharp style property get/set syntax for PHP | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50864@lists.php.net to get a copy of this message | ||
>> Interesting. So you are saying that once a word is a keyword in PHP, it
>> cannot be used as a name, anywhere? So for example, you are saying I
>> cannot create a variable called $function? If that is the case, that is
>> extremely odd. I would expect that get/set could be keywords when used
>> in
>> the right location (inside a property definition, but outside of the
>> property body), but anywhere else they should be able to be used as a
>> regular name... Is there some way that could be possible?
>
> A keyword in PHP means that it cannot be used as a name for something
> like a class/method/function etc. but of course still allowed in
> variable and constants (defined using define() -- not const as its
> compile time).
>
> class global { } /* fatal error */
> function default() { } /* fatal error */
Thanks for explaining that Kalle. I believe there is a way around this.
You mentioned using type-hinting syntax in an earlier email:
> You might also want to note in the RFC that "get" and "set" (which are
> very commonly used in userland code) will become keywords, unless you
> wish to take the same approach as with the current type hinting syntax
> we have in php-trunk that only makes type names have a meaning if they
> are in a prototype.
Could this easily be used (and would it make sense to use them) in this
situation? I think the best solution is for get/set to be keywords, but
only in the context of a property definition. Will this accomplish the
task?
- Dennis