And finally a couple of items that came up in discussion at the last
face-to-face. (Mark Miller's idea, somewhat generalized.)
(1) 'const' assigns the manifest type of value stored to the
the property that is created, ie, this expression is true:
{ const x: "foo" } is { x: string }
(2) 'const' can prefix the entier object literal, meaning that
all properties in the literal are 'const':
const { x:"foo", y:true } is { x:string, y:boolean }
(3) The prefix form can also be applied to array literals:
const ["foo",true] is [string,boolean]
This last bit makes it less painful to use arrays for multiple
return values ("tuples") because the literal does not have to
be annotated with the type:
function f(): [string,boolean] {
...
return const ["foo",true]
}
IMO it ought to be possible to use 'var' in those same ways but we
didn't discuss that much (if at all).
--lars
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Lars Hansen
> Sent: 21. mars 2008 11:04
> To: [email protected]
> Subject: RE: ES4 draft: Object initializers
>
> Another feature I forgot to include is ticket #370, the type
> annotation on an object initializer can be a nominal type in
> some cases. (The trac seems to be down, so I can't quote
> details. Anyhow I'm not sure if this ticket was ever
> discussed in a meeting, so it remains speculative.)
>
> --lars
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Lars Hansen
> > Sent: 21. mars 2008 08:19
> > To: [email protected]
> > Subject: RE: ES4 draft: Object initializers
> >
> > A bug: repeated fields are also disallowed if the object
> initializer
> > has a type annotation.
> >
> > In summary, only object initializers that look like ES3
> initializers
> > are allowed to have repeated fields (for backward compatibility).
> >
> > --lars
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Lars Hansen
> > > Sent: 20. mars 2008 16:43
> > > To: [email protected]
> > > Subject: ES4 draft: Object initializers
> > >
> > > I've attempted to sum up everything we have decided about object
> > > initializers (aka object literals). A short draft spec
> is included.
> > > Comments welcome from everyone, especially from ES4 WG
> members who
> > > might remember about things I've forgotten, or correct
> > > misunderstandings.
> > >
> > > --lars
> > >
> > _______________________________________________
> > Es4-discuss mailing list
> > [email protected]
> > https://mail.mozilla.org/listinfo/es4-discuss
> >
> _______________________________________________
> Es4-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es4-discuss
>
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss