Runtime support for function-results-as-lvalue

RESOLVED FIXED

Status

Rhino
Core
--
enhancement
RESOLVED FIXED
13 years ago
13 years ago

People

(Reporter: Igor Bukanov, Assigned: Igor Bukanov)

Tracking

Details

Attachments

(1 attachment)

(Assignee)

Description

13 years ago
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.
(Assignee)

Comment 1

13 years ago
Created attachment 188183 [details] [diff] [review]
Implementation

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.

Comment 2

13 years ago
(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.
(Assignee)

Comment 3

13 years ago
I committed the patch
Status: NEW → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.