Don't you think it's bad idea to use the same 'const' syntax, but
different behavior?
I believe it would be really confusing for users, as class constants are
set in compile time, thus 'const DIR = dirname(__FILE__);' is not possible.
That's a good point. However, "constant constants" - i.e., ones not
allowing expressions - would be much less useful, since many uses of the
constants - as used by define() - imply runtime evaluation - such as
pathes, configuration-derived variables, etc.
On the other hand, const in classes indeed doesn't allow us to define
runtime expressions. This is, however, offset by the fact that we have
per-class variables, where we can store expressions. In namespaces we
don't have (and probably don't want) per-namespace variables, so if you
need to keep something like dirname(__FILE__) somewhere inside
namespace, you have no option.
We could try to solve this by changing const to some other keyword. The
downside would be that we'd have further complicated the syntax. We
could modify define() or add ns_define() which would automagically add
namespace prefix. More options?
If anybody has any good idea of how to solve this, suggestions are
welcome. The summary of the problem is as follows:
1. We need some syntax to define per-namespace values.
2. For these values are to be useful they should allow runtime definition
3. const syntax looks like class constants which allow only compile-time
definition
--
Stanislav Malyshev, Zend Software Architect
[EMAIL PROTECTED] http://www.zend.com/
(408)253-8829 MSN: [EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php