[m-rev.] diff: varset.m cleanup
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Dec 21 22:42:29 AEDT 2003
On 21-Dec-2003, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> This diff makes varset.m easier to read and to maintain, but contains no
> changes in algorithms whatsoever.
>
> library/varset.m:
> Use predmode declarations and state variable syntax when appropriate.
>
> Add field names to the varset structure, and use them to improve
> readability.
...
> varset__name_var(VarSet0, Id, Name, VarSet) :-
> - VarSet0 = varset(MaxId, Names0, Vals),
> + Names0 = VarSet0 ^ var_names,
> map__set(Names0, Id, Name, Names),
> - VarSet = varset(MaxId, Names, Vals).
> + VarSet = VarSet0 ^ var_names := Names.
I would recommend writing that as
varset__name_var(VarSet0, Id, Name, VarSet) :-
VarSet = VarSet0 ^ var_names ^ det_elem(Id) := Val.
> +varset__bind_var(VarSet0, Id, Val, VarSet) :-
> + Values0 = VarSet0 ^ var_values,
> + map__set(Values0, Id, Val, Values),
> + VarSet = VarSet0 ^ var_values := Values.
Likewise here.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list