Daniel Jänecke skrev:
> I don't get the point of it. IMO this will only add another level of
> confusion to sourcecode; unless someone has a real good example (better
> than those in the posted link) where this technique is required I cannot
> see which benefit this feature adds.
>
1. Neither daniel nor Stanislav pointed to a previous discussion. I
therefore suppose this topic never has been brought up before.
2. Block scope is part of quite a few languages. Does it serve any
purpose in C, C# or Java? Does "my" and "local" serve any purpose in
PERL? [1] Heck, even VB.net has block scope![2]
I am not saying that PHP must have it just because it exists in other
languages - far from it! But it can not be *that* hard to imagine use cases.
3. Why do I think this idea is worth discussing? What is my use case?
My main contact with PHP nowadays is teaching it. And my students are
usually newbies to web development. Real namespaces is quite a long way
away from their understanding. Not everyone is a Bill Joy, a Linus
Torvalds or a Rasmus Leerdorf!
Many students - and other newbies - will cut and paste as a part of
their learning process. So even for more simple procedural code there is
a point in being able to hide variables from one snippet to another.
I consider block scope a sort of "namespaces light", an easy to
understand first step. As JS 2 will have the "let" keyword - and to most
newbies JS will be the principal "other" language besides PHP - a
similar construct would be easy to grasp.
To what extent block scoping would require a rewrite of PHP internally
is beyond my grasp. If this would put off the release of PHP 6 by 6
moonths it's not worth it. If it would delay PHP 6 one week, it might be
- IMHO.
Lars Gunther
1. http://perl.plover.com/FAQs/Namespaces.html#C_local_and_C_my_
2. http://msdn2.microsoft.com/en-us/library/1t0wsc67(VS.80).aspx
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php