Hi!
We have the same with global and static. Can you write them in the middle of a funciton/method? So asking for what the consequence is, is irrelevant
Yes you can. Example: <?php $a = 1; function foo() { $a = 2; echo $a; global $a; echo $a; } foo();
that it would break most PHP applications out there. Next, we chose 'use' for the keyword, knowing that it was already used elsewhere, dciding that it is the lesser evil opposed to creating yet another keyword with all implications of that. So this part is irrelevant to my point as well.
You are trying to make it greater evil that it would be otherwise, by making syntax that does different things look exactly the same.
In fact 'use' means create a static variable from the surrounding context,
If you ignore the referencing semantics. Which you should not.
And to answer the other question. Obviously 'sttaic' and 'use' are executed at compile time, so whereever you place them, they are executed before
Actually, static is a runtime construct - it generates FETCH_W opcode and ASSIGN_REF opcode.
So here consistency means placing a syntactical element at the same syntactical location related syntactical elements are placed.
The problem is that location is different (you can put static in the middle of the code, and you can't put use there) and semantics is different (static $a is by ref, use $a is not). Only thing similar is that you work with variables in both cases. But if you compare to function parameters, semantic is identical - it happens when entering a function, it is specified at the start, it can be by-val or by ref. The fact that inside engine it is implemented by reusing static's code is not reason enough to expose the user to it.
-- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php