destructuring in formal parameters?

# Peter Michaux (17 years ago)

I've passed a single object to a function in order to simulate named parameters. This requires some destructuring at the top of the called function.

function f(params) { var foo = params.foo; var bar = params.bar; //... } f({foo:1, bar:2});

With destructuring this could be reduced to

function f(params) { var {foo, bar} = params; //... }

f({foo:1, bar:2});

Could it be reduced even further to the following syntax?

function f({foo, bar}) { //... }

f({foo:1, bar:2});

Peter

# Brendan Eich (17 years ago)

On Nov 13, 2008, at 2:57 PM, Peter Michaux wrote:

With destructuring this could be reduced to

function f(params) { var {foo, bar} = params; //... }

f({foo:1, bar:2});

Could it be reduced even further to the following syntax?

function f({foo, bar}) { //... }

f({foo:1, bar:2});

This was in the ES4 proposal, and it's implemented in Firefox 3 /
JavaScript1.8:

js> function f({foo, bar}) { return [foo, bar]; }

js> f({foo:1, bar:2});

1,2

IIRC formal parameter destructuring was Harmonious when I presented it
in July.

# Peter Michaux (17 years ago)

On Thu, Nov 13, 2008 at 3:29 PM, Brendan Eich <brendan at mozilla.com> wrote:

This was in the ES4 proposal, and it's implemented in Firefox 3 / JavaScript1.8:

js> function f({foo, bar}) { return [foo, bar]; } js> f({foo:1, bar:2}); 1,2

Thanks.

IIRC formal parameter destructuring was Harmonious when I presented it in July.

Is there a published list of things which are considered "harmonious"? I'm particularly curious how lambdas have be received by the technical committee members after the long discussions and also classes as sugar.

Thanks, Peter

# Brendan Eich (17 years ago)

On Nov 13, 2008, at 3:33 PM, Peter Michaux wrote:

On Thu, Nov 13, 2008 at 3:29 PM, Brendan Eich <brendan at mozilla.com>
wrote:

IIRC formal parameter destructuring was Harmonious when I presented
it in July.

Is there a published list of things which are considered "harmonious"?

You asked last time and I answered:

esdiscuss/2008-August/007013

The only changes since then have been visible on es-discuss -- mainly
lambda, lexical scope, and the agreement to use an unambiguous bottom- up grammar, which rules out expression closures as proposed (and
implemented).

The strawman:strawman is the
place to look.

I'm particularly curious how lambdas have be received by the technical committee members after the long discussions and also classes as sugar.

I missed the last TC39 meeting, but the reaction on the list from Mark
Miller has been positive (indeed, instrumental in the case of lambdas).

# Peter Michaux (17 years ago)

On Thu, Nov 13, 2008 at 4:42 PM, Brendan Eich <brendan at mozilla.com> wrote:

On Nov 13, 2008, at 3:33 PM, Peter Michaux wrote:

On Thu, Nov 13, 2008 at 3:29 PM, Brendan Eich <brendan at mozilla.com> wrote:

IIRC formal parameter destructuring was Harmonious when I presented it in July.

Is there a published list of things which are considered "harmonious"?

You asked last time and I answered:

esdiscuss/2008-August/007013

The only changes since then have been visible on es-discuss -- mainly lambda, lexical scope, and the agreement to use an unambiguous bottom-up grammar, which rules out expression closures as proposed (and implemented).

The strawman:strawman is the place to look.

As far as I understand, the things on the strawman pages could have no chance of ever making it into the next major revision of ES. I was hoping for a place I could go for a periodically updated summary of the things generally considered harmonious. I thought between the time I asked previously and now that sort of page may have appeared.

I'm particularly curious how lambdas have be received by the technical committee members after the long discussions and also classes as sugar.

I missed the last TC39 meeting, but the reaction on the list from Mark Miller has been positive (indeed, instrumental in the case of lambdas).

Great.

Peter

# Brendan Eich (17 years ago)

On Nov 13, 2008, at 5:08 PM, Peter Michaux wrote:

On Thu, Nov 13, 2008 at 4:42 PM, Brendan Eich <brendan at mozilla.com>
wrote:

You asked last time and I answered:

esdiscuss/2008-August/007013

The only changes since then have been visible on es-discuss -- mainly lambda, lexical scope, and the agreement to use an unambiguous
bottom-up grammar, which rules out expression closures as proposed (and
implemented).

The strawman:strawman is the
place to look.

As far as I understand, the things on the strawman pages could have no chance of ever making it into the next major revision of ES.

It's not useful to say "could have no chance" -- the subjunctive mood
applied to "chance" means "could have every chance" is possible too.
Why write either?

What is likely remains to be seen, but the strawman pages all have a
good chance of getting in. Otherwise we wouldn't be spending time on
them.

Since we are not starting from a blank slate, the strawman namespace
is not anything-goes. It contains candidate material for the harmony
namespace, based on positive discussions here and in TC39, which is
meeting next week.

Please feel free to start (or re-start) discussion on anything in
strawman: on the wiki.

I was hoping for a place I could go for a periodically updated summary of the things generally considered harmonious.

I'll make such a page and confirm its contents at next week's meeting.