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

Peter Hawkins hawkinsp at cs.stanford.edu
Tue Sep 8 13:22:24 AEST 2009


Hi...

On Mon, Sep 7, 2009 at 7:53 PM, 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.

But you don't need many extra variants per procedure --- if the
updateField() method is part of an interface implemented by the class
in question, then the callee does not need to know the precise type of
the object to update its fields.

Ok, I'll shut up now.

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