thanks, Dave, some lateral thinking is really helpful. more below
On Oct 31, 2011, at 12:43 PM, David Flanagan wrote:
> I've been noodling around with various syntax ideas in this post, and it has
> gotten pretty long, so here are the highlights:
>
> var obj = base <| {a:1,b:2}; // I think its okay as-is.
> var obj = {:base> a:1, b:2}; // Its not really an operator, anyway
> var obj = base prototype {a:1,b:2} // Prototype with pride!
> var obj = base share {a:1,b:2} // JS: the friendly language
> var obj = with(base) {a:1, b:2}; // :-)
what do you think of <: instead of <| ?
>
...
> eem to increase the line-noise quotient of the language. But the triangle
> operator isn't one of those.
>
> If the concern is just about the typography of <| not looking triangular
> enough, how about <*, where < shows the direction of the relationship and *
> says "this is really special and important" :-) Or, <-?
if ( a<-5) ...
>
> It is also worth thinking about the fact that <| is a very unusual operator
> because the RHS must be a literal. Like the . operator for property access
> which requires an identifier on the right, it could be considered a syntactic
> form that is not quite an operator.
yes, that is what it is.
> ...
> Or, to emphasize that this new syntactic form is all about specifying a
> prototype for an object (or array, function, or regexp) how about forcing it
> all to be within curly braces?
>
> var obj = {:base> a:1, b:2};
> var arr = {:base> [a,b,c]};
> var func = {:base> function(...args) {...}};
> var re = {:base> /pattern/g};
>
> (I'm using a colon here instead of the vertical bar because I'm still hoping
> for block lambdas...)
interesting idea, an universal object literal form...
We should experiment with what it looks like when base is a more complex
expression.
>
> Setting a prototype on an array object is an unusual enough thing to do that
> I think it can certainly justify the wrapping and even extra indentation that
> comes with putting [] inside {}.
>
> If its got to be an infix keyword operator, I'm not crazy about "beget". I'd
> prefer "proto". And actually, I'd even prefer to type the extra 4 characters
> and use "prototype" because it is a verb. JavaScript has prototype based
> inheritance, so let's wear that proudly and make it a keyword operator.
>
> The next best I can come up with is "share". (That is assuming that "sub"
> and "subclass" are off-limits because ES.next.next may someday have a "class"
> keyword.)
>
> If the left and right-hand sides of the operator were swapped, it would be
> easy to name the operator: "inherit" would be an obvious choice. We need
> the inverse of "inherit", something like "designate an heir", but I don't
> think English has a word with that meaning. The word "heir" itself is nice
> and short, but I assume that the fact that it is not a verb disqualifies it.
"bequest"
>
> So if we can't find a good keyword using the
> inheritance-by-children-upon-death-of-the-parents metaphor, we can go for
> parent/child metaphors, which is where beget comes from. And from biology we
> can go back to inheritance in the form of genetic inheritance. If the
> prototype object is like DNA (and its properties are genes) is there a verb
> we can draw from genetics to describe what the operator does?
>
> Or, can we just break away from the family tree/inheritance metaphor entirely
> and just say what the operator does? That's where my "share" suggestion
> comes from: the prototype object shares its properties with the derived
> object.
>
> David
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss