How about replacing <| with ->

Dean Landolt dean at
Sat Mar 3 08:51:00 PST 2012

On Sat, Mar 3, 2012 at 11:08 AM, John J Barton
<johnjbarton at>wrote:

> On Sat, Mar 3, 2012 at 6:54 AM, Dean Landolt <dean at> wrote:
> > One argument for the "wrong direction" being wrong: if A <: B is common
> math
> > syntax for A is a subtype of B, if you turn the arrow around it'd read A
> is
> > a supertype of B, and this is fairly close to what <| was trying to
> express.
> I think the reason that we don't all instantly agree on the direction
> is simple: the operation is not directional. The operation is
> composition; the operands are not types but components of a type.
> Thus I think a 'natural' feeling syntax won't be arrow-ish.

What you're describing sounds a lot more like trait composition than
prototypal extension. While that'd be great it's already been nixed for
this go-round. I don't really think of this op as a function composition
but regardless, it's definitely a non-commutative binary operation -- there
are two arguments and the order matters a great deal. We just have to
decide what order. But yeah, it's pretty arbitrary, and both prior art and
intuition seem a bit muddy :-/

Speaking of compositions though, I can't recall if it was ever discussed
whether this operator can be chained, and if so, whether it associates. I
don't see too much value in this since references to any intermediate
constructions would only be available by walking the proto chain. I can't
think of a great use case, just curious if it's been considered and/or

> Ultimately Allen is attempting to provide some of the benefit of
> setting __proto__ while avoiding some of its problems.  Perhaps a
> syntax closer its home?  eg something like a set-prototypeOf property
>  { ^:MyObject.prototype, a:1,b:2}
>  [0,1,2,3,4,5].^ = appArrayBehavior
>  let subclass = Function.create(superclass, {});

 var p  = /[a-m][3-7]/.^ = newRegExpMethods;

This style of syntax suggests that it could be used after creation just the
same, e.g.:

var p = /[a-m]-3-7]/; p.^ = newRegExpMethods;

Since setting __proto__ may only happen at the moment of construction this
would have to result in a confusing syntax error (fancy AST reductions
notwithstanding). IIRC this is one reason Allen gave for the syntax he
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list