Finding a "safety syntax" for classes

Allen Wirfs-Brock allen at
Wed Mar 21 11:25:49 PDT 2012

On Mar 21, 2012, at 6:25 AM, Russell Leggett wrote:
> Yeah - that is the way I was leaning, partly because I like it, and partly because that was the behavior in <| for functions in the class pattern. I think it could help make it easier for people to fill the gaps in the minimal syntax. For example, many class libs have some mixin functionality. If mixin were added to a custom base class, then you could do:
>     class Foo extends MyBase {
>         ...
>     }.mixin(enumerable);

There are likely issue with the above syntax.  However, I can imagine someway saying:

class Foo extends mixin(MyBase, enumerable) {

where mixin is defined as:

function mixin(directSuper, ...mixins) {
    let effectiveSuper = class extends directSuper{ constructor(...args) {return super.constructor(...args)}};
    for (let m of mixins) Object.extend(effectiveSuper.proto,mixins);  //probably need some conflict resolution logic
    return effectiveSuper

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list