Strict mode recap

Jon Zeppieri jaz at
Fri Apr 11 10:05:16 PDT 2008

On Fri, Apr 11, 2008 at 12:17 PM, Lars Hansen <lhansen at> wrote:
>  One motivation is that programmers are likely to prefer the Java-like
>  syntax where the namespace (in its role as access control) shows
>  up early:
>   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.

Yep, I agree with this, too.  I certainly wouldn't want to mandate

    var public::x

in classes and wouldn't really want to write it myself.  But there's
some value in having a single, canonical syntactic form that will work
everywhere.  (If ES5 adds some kind of macro system, it would be more

>  Classes are sort of funny since you can consider a property name
>  in a class both as a property on the instance ( 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.

I agree with you on the natural syntax.  I'm not too sure, however,
that the property name/scoped variable thing is much more than a
visual pun.  (It would be different if classes were specified as
closure creation sugar.)  In

    class A {
        public var x;

        public function getX() x

I tend to think of the reference to 'x' as an elliptical form of
'this.x'.  And then there is

    class A {
        public var x;

        public static function brokenGetX() x

... where the "scoped variable" analogy doesn't work.


More information about the Es4-discuss mailing list