Closed Bug 299613 Opened 19 years ago Closed 19 years ago

Runtime support for function-results-as-lvalue

Categories

(Rhino Graveyard :: Core, enhancement)

x86
Linux
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

Details

Attachments

(1 file)

Currently Rhino has very limited runtime support for implementing
function-results-as-lvalue. In particular it requires to subclass BaseFunction
to override its callRef method. This is very inconvenient since to support the
notion like

foo() = bar

where foo is a host object implementing Scriptable interface one forced to
extend BaseFunction witch could force significant refactoring.

The idea would be to introduce a new interface that extends Callable to denote
an object where () can return an lvalue represented as Ref subclass in Rhino.
Attached patch ImplementationSplinter Review
The patch adds RefCallable interface extending Callable and updates code
generation/runtime to call refCall method in the new interface when necessary.
Another important consequence of the patch is that it changes implementation of
"()" operator to require only Callable interface, not Function for its target.
In this way host objects that needs to support cases like:

matrix(0, 1) = 1; 
matrix(1, 2) = matrix(0, 1);
matrix(0, 1) += 10;

would just need to implement RefCallable in addition to Scriptable and not
worry about implementing Function.construct which is not necessary in this
case.
(In reply to comment #1)

I was wondering if RefCallable should extend Callable or can be just an 
independent interface, to make it even more flexible.

Anyway if you can keep this change - and test only for Callable/RefCallable 
where you used to test for Function or BaseFunction - will help a lot in 
embeddings, sometimes Function is too heavyweight.
I committed the patch
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: