[mercury-users] Field updates and state variables
Peter Hawkins
hawkinsp at cs.stanford.edu
Mon Jul 3 13:09:35 AEST 2006
Hi..
On Jul 2, 2006, at 7:26 PM, Peter Schachte wrote:
> On Sun, Jul 02, 2006 at 12:28:06PM -0700, Peter Hawkins wrote:
>> Hi...
>>
>> I find myself writing code like this a lot:
>> ...
>> !:S = !.S ^ my_map := map.insert(!.S ^ my_map, Key, Value)
>> ...
>>
>> Wouldn't it be nice if I could write the field update as:
>> map.insert(Key, Value, !S ^ my_map)
>
> That seems pretty magical; the former is not what I would naturally
> expect the latter to expand to.
Well, to be precise I actually meant it to expand to this:
map.insert(Key, Value, !.S ^ my_map, Temp),
!:S = !.S ^ my_map := Temp,
This hopefully is more obvious. I'm open to something like the elem
trick --- I just want a little less typing for updating objects
inside state variables.
Cheers,
Peter
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list