> 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]
Funny that you ask, because Perl docs you linked specifically say
"local" does not serve any real purpose, is extremely confusing and they
have it only for BC reasons. "my" does serve a purpose, but in Perl
scopes are a bit different from PHP (anonymous functions, etc.) so
per-scope local variables make more sense.
> 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.
If it isn't so hard to imagine them, it shouldn't be hard to post them,
right? ;)
> 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!
That's one reason why we work hard to keep the language simple, while on
the other hand trying to make it powerful enough to be useful. These are
contradicting goals, so finding a balance between them is not easy.
That's why new features must be carefully weighted - how much
complication does it add? How much power? Is is worth it?
Naturally, if one proposes something, it is expected that he'd make the
first argument towards proving the worthiness - which may or may not be
supported by the community.
> 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.
function? :)
> 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.
I seriously doubt that many newbies need Javascript features that
appeared only in 1.7 - such as let blocks with advanced scoping rules -
or really understand them. Javascript is rather complicated (and
powerful) language - definitely more complicated than PHP, IMHO.
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com