views:

70

answers:

0

Here's an interesting question that could provide useful input into the Spidermonkey flavor of Javascript (used in Firefox & other programs)...

The original was in a post on mozilla.dev.tech.js-engine but i'll quote here as well:

Newsgroups: mozilla.dev.tech.js-engine
From: Brendan Eich <[email protected]> 
Date: Fri, 7 Aug 2009 12:05:45 -0700 (PDT) 
Local: Fri, Aug 7 2009 3:05 pm 
Subject: Proposed SpiderMonkey extension removal: o.item(i) = ...; JS_SetCallReturnValue2

Thanks to the malign influence of VBScript, IE JScript has long supported call expressions as lvalues:

j = d.item(i); // get d[i] 
d.item(i) = k; // set d[i]

This extension is not needed for Web compatibility AFAIK, but it occasionally shows up in ASP.NET and other content, some of which then wants to be hosted by SpiderMonkey. So, long ago I added this "lvalue return" feature to SpiderMonkey -- but only for the case where the method (item in the example) is native. See https://bugzilla.mozilla.org/show_bug.cgi?id=44997.

We'd like to remove this SpiderMonkey extension. It will not be standardized in any ECMA-262 Edition, although the spec allows "host objects" to return Reference internal type instances. The implementation was done in 2000 when SpiderMonkey had only a feature- ful and pretty unoptimized interpreter. Now the code to support Reference type return is an albatross.

Anyone object? If so, why are you using this extension? Please show examples and some kind of rationale for this VB-ism. It's likely if you can't avoid using this feature, you'll have to stick to a downrev SpiderMonkey soon.


Is there any reason for keeping this feature (I never knew about it!) ? The only thing I can think of is that

obj.extractSomeField(someArgument) = foo

is just syntactic sugar for

obj.setSomeField(someArgument, foo)

and anyone who designs an object with a method that returns an lvalue but does not provide a set-function(), deserves what they get if this feature is removed.

Anyway I'm really interested in thoughts of people here as the newsgroup doesn't get that much traffic/attention.