Given the recent go at finding alternative syntax for the <| operator, I
thought about it and decided to split the functionality between creating
"instances" using alternative prototypes, and the other side of the fence
making reusable extended objects easier to make.

Its a little long so I threw it in a gist: https://gist.github.com/2056771

Summary:

In the case of creating what I would call an instance (not meant to create
further instances) I have small, tight syntax:

    //using : instead of <|, shorten Email.prototype to just Email
    let email = Email:"russell.legg...@gmail.com";
    if(email.isValid){
        email.sendMessage({
            subject: "Hello!",
            body: "you won't find this on a normal string, dude"
        });
    }

and in the case of extension, rely on some class syntax getting approved:

    class Email extends String {
        get isValid:function(){...}
        ...
    }

There even an added bonus of a simple short-function syntax

    let f = Function;
    [1,2,3].map( f:(num){return num * 2;} );

where : is in place of <| and the 'function' keyword can get dropped on the
RHS.

- Russ
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to