[mercury-users] Field updates and state variables (more)
Peter Schachte
schachte at csse.unimelb.edu.au
Wed Jul 19 10:29:04 AEST 2006
On Wed, Jul 19, 2006 at 01:12:38AM +1000, Nicholas Nethercote wrote:
> Hi,
>
> Peter Hawkins recently proposed this syntax for updating fields in state
> variables:
>
> map.insert(Key, Value, !S ^ my_map)
>
> to mean this:
>
> map.insert(Key, Value, !.S ^ my_map, Temp),
> !:S = !.S ^ my_map := Temp,
How about:
!S ^ my_map ^ elem(Key) := Value
Should work right now, and it's less verbose than the syntax you
suggest. OBTW, you can also write
!S ^ my_map ^ elem(Key)
as an expression in place of
map.lookup(!.S ^ my_map, Key).
I agree that Peter's suggestion would be a natural and useful
extension, but the pseudo-record access syntax is pretty natural and
clean, and emphasizes the symmetry between lookup and insertion.
--
Peter Schachte The only thing necessary for the triumph of evil
schachte at cs.mu.OZ.AU is for good men to do nothing.
www.cs.mu.oz.au/~schachte/ -- attributed to Edmund Burke
Phone: +61 3 8344 1338
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at csse.unimelb.edu.au
administrative address: owner-mercury-users at csse.unimelb.edu.au
unsubscribe: Address: mercury-users-request at csse.unimelb.edu.au Message: unsubscribe
subscribe: Address: mercury-users-request at csse.unimelb.edu.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list