Alternative syntax for <|

Brendan Eich brendan at mozilla.com
Wed Nov 16 10:56:09 PST 2011


On Nov 16, 2011, at 8:19 AM, Russell Leggett wrote:

> On Wed, Nov 16, 2011 at 11:07 AM, Jake Verbaten <raynos2 at gmail.com> wrote:
> It's simply that 
> 
> var x = someProto beget { ... }
> 
> reads nicer then
> 
> var x = someProto extends { ... }
> 
> I'd prefer to have readability on the non class related operator then the class related operator
> 
> I was actually suggesting extends on the left - so
>  
>     var x = extends someProto { ... }
> 
> Which reads better than someProto extends { ... }, because that reads as though {...} is the parent.

I think you cracked an important problem here. Someone on my blog commented "why not infix extends" (my paraphrase) but with proto on the left that's backwards. Putting proto on the right of infix 'extends' does not work well because the object literal on the left can be large, making the extends and the (generally shorter) proto expression hard to see. More to your point, that also misaligns with

class C extends B {...}.

If we can get class as a unary operator right, or even if not due to <| looking bad in too many common fonts, then your prefix binary 'extends' operator looks winning to me. It's not perfect, but nothing is.

/be

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


More information about the es-discuss mailing list