[m-dev.] lcmc for high-level data

Peter Wang novalazy at gmail.com
Tue Sep 8 13:50:10 AEST 2009


On 2009-09-08, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> On 07-Sep-2009, Peter Hawkins <hawkinsp at cs.stanford.edu> wrote:
> > Not knowing the specifics of the transformation in question, rather
> > than using reflection, couldn't you do add a method to the object
> > whose field is to be updated along the lines of:
> > 
> > void updateField(int field_number, Object o) {
> >   switch (field_number) {
> >     case 0: this.a = (TypeA)o; break;
> >     case 1: this.b = (TypeB)o; break;
> >     ...
> >   }
> > }
> > 
> > The transformation needs to ensure that the appropriate field number
> > is passed from caller to callee together with the object base pointer,
> > and the callee should call the updateField method to write to the
> > field.
> 
> My guess is that Peter Wang was talking about this exact scheme of code
> generaton.

No, I actually was talking about reflection in the footnote.

The updateField() scheme requires both the object base pointer and field
number to be passed in, but the number of variant procedures would not
increase.

On the other hand, creating variants that know which structures and
fields they are updating is likely to be faster, but could create too
many variants.  I think it's acceptable to just disable the optimisation
if too many variants would be produced, so I'll try this first.

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