Re: Re: import/use last call
| From: | Gregory Beaver | Date: | Tue, 23 Oct 2007 18:56:30 +0000 |
| Subject: | Re: Re: import/use last call | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32934@lists.php.net to get a copy of this message | ||
Giedrius D wrote:
> On 10/23/07, Gregory Beaver <greg@chiaraquartet.net> wrote:
>
>> The same confusion that is brought about by allowing keywords as
>> variable names?
>>
>> <?php
>> class Test
>> {
>> public $class;
>> }
>>
>> $a = new Test;
>> $a->class = 1;
>> ?>
>>
>> Is this next example any more confusing?
>>
>> <?php
>> class Test
>> {
>> function class(){}
>> }
>>
>> $a = new Test;
>> $a->class();
>> ?>
>>
>> I think you're confused by what is proposed :).
>>
>
> Yes you are right about the methods but consider something like this:
> <?php
> namespace (Foo::Bar);
> import(new new);
>
parse error - of all reserved words, only "namespace" and "import" are
allowed as class names in my patch
> // etc.
> ?>
> Looks kinda odd to me although it might have sense in some context.
>
> Anyway my main question was: is there any reason not to use keyword "use"?
The only reason for me is that "use" implies some kind of autoloading,
as I suggested in one of my other mails. This gets into parsing
semantics, something I'm not interested in doing. If the folks go with
"use" that is fine, but for me personally not the best solution, which
is why I put hours into making this patch.
However, no matter what I definitely would like to see code written for
PHP 5.2 and earlier that uses "import" or "namespace" as class names or
functions continue to work in PHP 5.3. "namespace" is used commonly for
XML information (for obvious reasons), and import is a very common idea,
as already stated.
Greg