Strict mode recap

Jon Zeppieri jaz at bu.edu
Fri Apr 11 08:50:16 PDT 2008


On Fri, Apr 11, 2008 at 11:42 AM, Lars Hansen <lhansen at adobe.com> wrote:
> > -----Original Message-----
>  > From: zeppieri at gmail.com [mailto:zeppieri at gmail.com] On
>  > Behalf Of Jon Zeppieri
>
> > Sent: 11. april 2008 09:26
>  > To: Lars Hansen
>
> > Cc: es4-discuss at mozilla.org; liorean
>  > Subject: Re: Strict mode recap
>  >
>
>
> > On Fri, Apr 11, 2008 at 11:04 AM, Lars Hansen
>  > <lhansen at adobe.com> wrote:
>  > >
>  > >  > Right, I get that, and Brendan's point was a good one.  I was  >
>  > > just thrown by the fact that I hadn't seen an example of  >
>  >  > class A
>  > > {
>  > >  >   var public::count = 10;
>  > >  > }
>  > >  >
>  > >  > rather than
>  > >  >
>  > >  > class A {
>  > >  >   public var count = 10;
>  > >  > }
>  > >  >
>  > >  > But if the former is legal (and the grammar suggests that it  >
>  > > is), then there's no inconsistency.
>  > >
>  > >  It is not legal, and if the grammar suggests that it is then  the
>  > > grammar is buggy.
>  >
>  > Okay, so why is it a good thing to mandate a different syntax
>  > for defining an object property in an initializer, on one
>  > hand, and defining a property of a class instance, on the
>  > other?  Don't get me
>  > wrong:  I understand the utility of allowing the "public var
>  > count = ..." syntax, where 'var' in interposed between the
>  > two parts of the name.  What I don't understand is why you
>  > wouldn't want a single, canonical syntax for expressing names
>  > in definitions.  "public var
>  > count": could just be sugar for "var public::count".  Or does
>  > that raise other problems...?
>
>  As I wrote earlier, the canoncial cases are { id: 10 } and { ns::id: 10
>  },
>  where the property is dynamic.  "var" and "const" are flags that make
>  the
>  properties into fixtures.  Having to split ns::id apart to interpolate
>  "var" does not appeal to me (at least).
>
>  I think you're getting hung up on the keyword.  We could choose another
>  keyword here to serve as the flag: { fixture ns::id: 10 } and there
>  would
>  not be a problem with that change particularly, but it also doesn't seem
>  to
>  serve any particularly good purpose to do so.
>
>  In other words
>
>   fixture { x: 10, y: 20 }   // instead of var
>   { fixture x: 10, y: 20 }   // x is a fixture, not y
>
>  and
>
>   readonly { x: 10, y: 20 }  // instead of const
>   { readonly x: 10, y: 20 }  // x is a readonly fixture, not y
>
>  and so on.  Did we gain anything in clarity?  Would we, if even
>  better keywords were chosen?
>
>  --lars


No -- I agree with everything you wrote here.  I like this syntax.
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,
anyway.)

I'm not suggesting allowing

    public var count: ...

in object initializers.  I think Brendan's reply to me on that was decisive.



More information about the Es4-discuss mailing list