Alternative syntax for <|

Quildreen Motta quildreen at gmail.com
Tue Nov 22 11:03:58 PST 2011


2011/11/22 Bob Nystrom <rnystrom at google.com>

>
> On Tue, Nov 22, 2011 at 10:41 AM, Brendan Eich <brendan at mozilla.com>wrote:
>
>>
>> Nothing there about arrays or regular expressions, and the function
>> examples do *not* show anything like
>>
>>  superFun <| function (...) {...}
>>
>> Instead of Ahem'ing, could you cite what you claim is a prior proposal
>> with specifics showing how it addresses object, array, regexp and function
>> [[Prototype]] presetting?
>>
>
> I'm guessing this been proposed before but I think you could handle all of
> those except RegExp with syntax something like:
>
> // object:
> { extends someObj, prop1: value, prop2: value }
>
> // array:
> [ extends someObj, value1, value2 ]
>
> // function declaration:
> function foo(arg) extends someObj { ... }
>
> // function expression:
> function(arg) extends someObj { ... }
>
> You could *maybe* cram it into RegExp with something like:
>
> /pattern/ extends someObj;
>
> I haven't been following the <| discussion closely (it seems like it's in
> good hands and has lots of smart people poking at it) so forgive me if this
> was proposed and rejected for valid reasons while I wasn't looking. :)
>
>
>From what I get of Claus' proposal, this is more or less what he's been
proposing.

Though he seemed to be proposing it from a type-decl/declarative stand
point:

type X :: JSObject (Proto proto) thing

to be roughy equivalent to `proto <| thing'.

which would be in turn roughly equivalent to the imperative form:

thing = {} | /regex/ | function(){ } | [] | 1 | "a"  // <- don't mind my
lazyness and treat this as several different kinds of possible objects in
the next statement
thing.[[prototype]] = proto

So, the <| syntax would be a declarative form that composes something of
the type in the RHS, having a prototype as LHS, thus working for any kind
of object -- just as __proto__ does.

Then he proposed using the same syntax for doing pattern matching on the
prototype chain, which sounds quite cool.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111122/ff42f430/attachment-0001.html>


More information about the es-discuss mailing list