David Herman dherman at mozilla.com
Thu Nov 17 09:11:34 PST 2011

On Nov 17, 2011, at 6:41 AM, Dmitry Soshnikov wrote:

> And uses `.extend' instance method (inherited from Object) for imperative delegation-based mixing.

Sure, so that's just a method then, not an `extends` keyword.

> OK, though, I'd like again to notice Scala:
> object foo extends bar {
>   ...
> }
> class Foo extends bar {
>   ...
> }

Right; in Scala it's still only part of a declaration syntax. Just in terms of being readable English, I don't think `extends` works as an operator. I think it only works as part of a declaration ("I declare that X extends Y"), or it would work as a boolean operator ("does X extend Y?"), but it doesn't work as an operator that creates a new object. You could do something like

    extend X with Y

but that would require a new reserved work `extend`. And it would be awkward to chain:

    extend (extend X with Y) with Z

> the same I proposed to ES (to avoid new keyword `object' I used simple `let' or `var'):
> let foo extends bar {
>   x: 100
> }

There are a number of things I don't like about this, but primarily the fact that it changes the uniform syntax of `let` or `var`. Notice how Scala always uses a special prefix keyword that is built to work with `extends`.

> Thus, answering your mail (sorry for not answered before), I can't say, whether `extends' is infix or prefix. I don't completely understood on "can be conditional keywords", but what prevents `extends' to be the same?

Oops, late night brain freeze. I meant to say "contextual keywords." When there's a grammar context that doesn't allow arbitrary identifiers, we can allow specific identifiers with custom meanings without them actually being reserved words. That's what we're doing for "of" in the for-of loop, and that's what we're doing for the "is" and "isnt" operators. They aren't reserved words.

But it doesn't work for prefix operators unless you use a reserved word. We have `extends` as a reserved word, so that works. But I don't like it for reasons of English, as I explained above (and in an earlier email).


More information about the es-discuss mailing list