prototype for operator proposal for review

Brendan Eich brendan at mozilla.com
Fri May 20 14:46:52 PDT 2011


On May 20, 2011, at 2:32 PM, Sean Eagan wrote:

> <: kind of looks like a jet with two rocket engines on the back which
> might be memorable.  It could be called the "jet operator" or "rocket
> operator".

On some fonts it looks pretty bad, though.


> <~ has the disadvantage that it looks somewhat similar to <- and thus ->

<~ and <- are not backward-compatible extensions, consider function test(a,b) { return a<-b; }.


> Also, whichever one is picked, why not allow it to point in either
> direction, just always towards the [[Prototype]] ?  Using the reverse
> direction for different semantics in the future would be confusing.
> The forward direction would be useful if you only wanted the
> [[Prototype]] to be used by one object:
> 
> {x: "x", y: "y"} ~> {
>  foo: function(){...},
>  bar: function(){...}
> }

The prototype object is typically named and therefore referenced on the left of the "proto operator", with an object initialiser that's must longer declaring the new object that delegates to the prototype object. This does not work well with forward-arrow, because it makes for readability eyesores like this:

var derived = {big: ...,
              lumpy: ...,
              initialiser: ...,
              withMethods(...) {...}} ~> proto;

where the ~> proto is lost in the ragged-right noise. Sure, you can pull it out onto its own line, but you still have the fat, lumpy initialiser squatting on it. Not pretty!

/be


> 
> 
> On Wed, May 18, 2011 at 6:20 PM, David Herman <dherman at mozilla.com> wrote:
>> It's okay in Courier New but not in lots of other popular monospaced fonts. See attached image.
>> 
>> Dave
>> 
>> 
>> 
>> 
>> On May 18, 2011, at 3:30 PM, Allen Wirfs-Brock wrote:
>> 
>>> 
>>> On May 18, 2011, at 3:14 PM, David Herman wrote:
>>> 
>>>>> I think I like <: about as much as  <|.  I'm not sure which is going to be more readable across a variety of fonts and sizes.  <| does seem to be generally more visually distinct.
>>>> 
>>>> I just have to say that the pipe symbol in many fonts makes for a really hideous triangle. It doesn't line up at all with the top and bottom of the less-than/greater-than symbols.
>>>> 
>>>>> I suspect that to most JS programmers the UML open triangle generalization arrow head is at least as relevant a precedent as any type theory uses.  In other words,the relevancy of either isn't very high.
>>>> 
>>>> Yeah. In fact, the analogy to type theory would have us read the <: symbol as a binary predicate, which isn't what's going on here at all.
>>>> 
>>>> So... I don't find either of these lexemes very pleasant, but I don't have any beautiful alternatives to offer.
>>>> 
>>>> Dave
>>>> 
>>> 
>>> It's highly variable, but on average they both generally look better in a mono-spaced fonts.
>>> 
>> 
>> 
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>> 
>> 
> 
> Cheers,
> Sean Eagan
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list