Stanislav Malyshev wrote:
>> that if you try to "combine" two files that contain import statements,
>> it will be necessary to expand the imports.  Fortunately, since
>
> What do you mean by "expand"?
>
>> import allows aliasing specific namespaced files and classes within a
>> file.  For example:
>
> But import has nothing to do with files. import works on names, not files.
s/files/functions/  I mis-typed and didn't notice, sorry.

>> <?php
>> namespace foo {
>> class bar {}
>> }
>> import foo::bar;
>> namespace gronk {
>> class bar {}
>> }
>> ?>
>>
>> Fatal error: Class name 'bar' coflicts with import name
>
> Ouch! So I can't actually combine namespaces from different areas -
> how I'm supposed to know when I write "gronk" that somebody is going
> to stick this code into the context that already has the name "bar" in
> it? It's exactly the problem namespaces are meant to solve! Moreover,
> if you take two files with working code and copy-paste them into one
> file, they have a lot of chance of stopping working. If this isn't
> confusion, I don't know what is.
Careful Stas :), you probably missed the "import foo::bar;" This code
works just fine:

<?php
namespace foo {
    class bar {}
}
namespace gronk {
    class bar {}
}
?>

No fatal errors, everybody is happy.  The problem is importing the "bar"
identifier.  This code also fails with the same fatal error for the same
reason:

file1.php:
<?php
namespace foo;
class bar {}
?>

file2.php:
<?php
namespace gronk;
import foo::bar;
class bar {}
?>

>> That will clear up any possible confusion.
>
> No, on the contrary - it would create a lot of confusion, since now
> you can break namespaced code with code outside namespace, which
> wasn't supposed to happen by definition.

It still doesn't.  As I pointed out above, the same error is possible
with the current implementation pre-my patch.

>> Well it kind of makes namespaces behave more like namespaces, don't you
>
> Please stop this "only C++ implementation is right" thing.
I don't care about C++.  I'm only talking about the patch I proposed.

Thanks,
Greg

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to