Strict mode recap
lhansen at adobe.com
Fri Apr 11 09:17:10 PDT 2008
> -----Original Message-----
> From: zeppieri at gmail.com [mailto:zeppieri at gmail.com] On
> Behalf Of Jon Zeppieri
> Sent: 11. april 2008 09:50
> The question is: why not apply it to classes, too?
> By the way, I was wrong about the grammar allowing
> var public::count = ...
> in classes. It doesn't. But why not allow it there and consider it
> canonical? (Doesn't 'var' also indicate that the property is a
> fixture in a class definition, too? It's not part of the name,
One motivation is that programmers are likely to prefer the Java-like
syntax where the namespace (in its role as access control) shows
public var count =
private var key =
I really think this is the "right" syntax for variables. The syntax
var private::key, private::foo, public::x, private::bar;
is certainly workable and unambiguous but
public var x;
private var key, foo, bar;
works better for me, because the access control is visible and
separated from the names, because each phrase is shorter, and
because I'm guaranteed to separate my privates from my publics.
Classes are sort of funny since you can consider a property name
in a class both as a property on the instance (o.id) but also
just as a scoped variable, inside all the methods of the class.
If you're *really* into Java the former case disappears completely
because there will be getter/setter pairs for everything ;) so the
"scoped variable" case is completely dominant. I'm not sure
that's wrong, and I think a variable declaration syntax is
more natural than an object property syntax.
(The syntax of field names in object initializers, on the other hand,
is a consequence of how that syntax has evolved.)
Matters of taste? To an extent. But preserving "brain print" from
other languages (Java, Python) is not unimportant, it's one of the
principles that have been used in designing the language.
More information about the Es4-discuss