AW: Basic Namespace Requirements

php.internals

Matthias Pigulla

20 years ago
> Von: Jessie Hernandez > So, the question is, can we scrap both namespace constants > and namespace functions and just stay with classes (as was > agreed on several months ago, Andi himself agreeing to it)?
...
> I think this is the best solution thus far. If any one of you > still feels a need for constants/functions, PLEASE show me a > _valid_ example that cannot be accomplished by just simply > putting the constant/function inside a class in the namespace.
Bart de Boer came up with a good reason for them so I'd like to re-post his statement. <quote> Namespace constants can be handy if you'd want to include some library that uses predefined constants and classes that might conflict with other classes and constants in the script. namespace someLib { include('huge_conflicting_library_that_I_dont_want_to_reverse_engineer') ; } </quote> Of course, that would not only require to put defines [=constants?] and functions in namespaces, but variables as well. namespace X { var $foo = 1; function bar($p) {} } X::bar(X::$foo); which can, of course, not easily be distinguished from static class members. So is the whole "include-legacy-stuff-into-namespace"-approach beyond the scope of what you're trying to do? -mp.

Jessie Hernandez

20 years ago
Matthias, Simply put, const != define. Like I think Sara mentioned before, defines are runtime-defined, and making it both compile-time/runtime defined based on context will be really confusing. Also, I'm not accepting variables in namespaces and this is not needed either. So, yes, this is outside the scope of what I want to accomplish. Regards, Jessie ""Matthias Pigulla"" <mp@webfactory.de> wrote in message news:00A2E2156BEE8446A81C8881AE117F192C1D5D@companyweb...
> Von: Jessie Hernandez > So, the question is, can we scrap both namespace constants > and namespace functions and just stay with classes (as was > agreed on several months ago, Andi himself agreeing to it)?
...
> I think this is the best solution thus far. If any one of you > still feels a need for constants/functions, PLEASE show me a > _valid_ example that cannot be accomplished by just simply > putting the constant/function inside a class in the namespace.
Bart de Boer came up with a good reason for them so I'd like to re-post his statement. <quote> Namespace constants can be handy if you'd want to include some library that uses predefined constants and classes that might conflict with other classes and constants in the script. namespace someLib { include('huge_conflicting_library_that_I_dont_want_to_reverse_engineer') ; } </quote> Of course, that would not only require to put defines [=constants?] and functions in namespaces, but variables as well. namespace X { var $foo = 1; function bar($p) {} } X::bar(X::$foo); which can, of course, not easily be distinguished from static class members. So is the whole "include-legacy-stuff-into-namespace"-approach beyond the scope of what you're trying to do? -mp.

Bart de Boer

20 years ago
I'm not sure I understand this problem. Isn't it doable to define defines at runtime and then put them under a certain namespace? I'm assuming namespaces are defined before defines? Ideally, I'd say there should be no code limitations inside namespaces. But if this poses technical problems. Then I think using only classes under namespaces is better then no namespaces. Jessie Hernandez wrote: