[mercury-users] Field updates and state variables (more)
Nicholas Nethercote
njn at csse.unimelb.edu.au
Wed Jul 19 12:18:06 AEST 2006
On Wed, 19 Jul 2006, Peter Schachte wrote:
>> 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.
I'm getting this error:
symbols.m:581: Error: expected `Field =^ field1 ^ ... ^ fieldN'
symbols.m:581: or `^ field1 ^ ... ^ fieldN := Field'.
symbols.m:581: in DCG field access goal.
symbols.m:546: Error: no clauses for predicate `add_symbol/5'.
Also, this relies on have the ^elem setter, which is fine when the record
element is a map, but not so good for anything else. Of course you could
write your own setter, but that's more typing, etc.
Nick
--------------------------------------------------------------------------
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