Reifying References?

Axel Rauschmayer axel at rauschma.de
Sun Dec 4 12:31:58 PST 2011


Any thoughts on whether it might make sense to reify References [8.7 in the ECMAScript 5 specification] in the language proper?

E.g. via a function ref() (as a strawman – not really syntactically viable).

Applications:

- Pass a variable by reference:
    function incReference(r) {
        if (! (r instanceof Reference)) {
            throw new TypeError();
        }
        r++;
    }
    incReference(ref(foo.bar.baz));
    incReference(ref(myVar));

- Data binding

- More options for the lhs of an assignment (advanced collections...)

- Possibly: simplify some of the getter/setter APIs, but it’s probably too late for that, because this approach has become standard.

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com





More information about the es-discuss mailing list