let function

C. Scott Ananian ecmascript at cscott.net
Tue May 19 16:39:06 UTC 2015

On Tue, May 19, 2015 at 12:24 PM, Steve Fink <sphink at gmail.com> wrote:

> That visually collides with destructuring for me.
> let [a, b] = foo();
> let {a, b} = foo();
> let f(a, b) = foo(); # Very different
> I almost expect that last one to use f as a custom matcher of some sort,
> given the previous two.

Well *there's* an interesting proposal.  As I understand it, this corner of
the grammar is free, so custom matchers would be a possibility here.

I can imagine some interesting uses for custom data types, eg:

let pair(a, b) = foo(); // like `let {head, tail} = foo();` but with custom
type checking.
let polar(radius, angle) = point(1, 2); // custom matcher can convert
between coordinate respresentations

or even build a simple matching case statement for a recursive decent

let for_statement(init, cond, incr) = input_text;

Does that spark ideas in anyone else?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150519/3193d693/attachment.html>

More information about the es-discuss mailing list