[m-dev.] lcmc for high-level data
Peter Wang
novalazy at gmail.com
Wed Sep 9 15:29:29 AEST 2009
On 2009-09-08, Ian MacLarty <maclarty at csse.unimelb.edu.au> wrote:
>
> Could you add an interface like the following:
>
> interface Ref {
> public void set(Object o);
> }
>
> Then, at the point you want to take the address of the field you
> construct an anonymous instance of this interface and use that:
>
> Ref r = new Ref() {
> public void set(Object o) {
> obj.field = (FieldType)o;
> }
> };
>
> obj would need to be final. If it's not already final you could
> always create a new final reference to it to use in Ref.
I've tried this out as it was relatively easy to do so. On a small
benchmark of append/3 the tranformed code ran ~30% slower due to the
extra memory allocation per iteration of the loop.
Peter
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions: mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the developers
mailing list