with

Axel Rauschmayer axel at rauschma.de
Thu Nov 17 05:37:38 PST 2011


[cc-ing es-discuss again]

On Nov 17, 2011, at 14:20 , Russell Leggett wrote:

> On Thu, Nov 17, 2011 at 6:17 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
>>>    obj with { foo: 12 } with { bar: 13 } with { baz: 17 }
> 
> I like the idea! As it is syntactically different in this role, errors should be easy to spot.
> 
> But I think `with` “points in the wrong direction” (object `obj` *with* prototype `proto`). That is, to me, it suggests a pointer going from prototype to object.
> 
>> My first answer was glib, sorry. I'm proposing `with' as a replacement syntax for <|. So the above expression evaluates to the same as
>> 
>>     obj <| { foo: 12 } <| { bar: 13 } <| { baz: 17 }
> 
> 
> The above example demonstrates just how well the <| operator works. The main objection to it is that it looks wrong in some fonts? Unless there is a general grawlix objection, something arrow-y would be great.
> 
> I would agree with you, except that it would never happen. When would you ever say
> 
>     obj <| { foo: 12 } <| { bar: 13 } <| { baz: 17 }
> 
> When you could just use one literal
> 
>     obj <| { foo:12, bar:13, baz:17 }
> 
> If <| changed to allow non-literal RHS values, I could see it getting more use
> 
>     obj <| comparable <| enumerable <| {...}
> 
> but right now, that has a big hurdle and I've yet to see anybody but me propose a solution.

True, that’s the catch. Then it works for composing an inheritance hierarchy (as in mixins as abstract subclasses).

Another idea for `extends` (if there is more than one object that is being extended):

     extends(comparable, enumerable, foo, bar) { ... }

Axel

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111117/902fa3fb/attachment-0001.html>


More information about the es-discuss mailing list