On Oct 13, 2010, at 5:14 PM, Brendan Eich wrote:
> Now consider if you had a third parameter to the 'get' trap to signal callee
> context vs. non-callee context. You'd still want to proxy the functions, that
> doesn't get simpler just due to a change of trap parameters. You'd still want
> to cache for identity. But you would have made invoke-only methods.
s/would/could/ in the last sentence -- the point is allowing get to tell when
the property is being accessed as the callee in a call expression (or new
expression? hmm) does not inevitably inject invoke only methods -- it simply
adds the degree of freedom that someone could use to implement them.
Since there's no savings in terms of apples-to-apples method proxying and
memoization ("caching") for ===, this degree of freedom seems strictly a
misfeature. Even __noSuchMethod__ fans would agree!
> Ok, let's give up on functional programming and cached methods. Here' s my
> version written to use only __noSuchMethod__, no proxies:
>
> function makeLazyMethodCloner(eager) {
> return Object.create(Object.getPrototypeOf(eager), {
> __noSuchMethod__: {
> value: function (name, args) {
> return eager[name].apply(eager, arguments);
s/arguments/args/
I was testing lightly. Again, the code posted here works in a current
mozilla-central or tracemonkey js shell, or (with s/print/console.log/g) in
Firefox 4 betas.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss