Re: dvar_domain

From: Warwick Harvey <wh_at_icparc.ic.ac.uk>
Date: Fri 08 Jun 2001 01:07:40 PM GMT
Message-ID: <20010608140740.E709@tempest.icparc.ic.ac.uk>
Hi,

On Fri, Jun 08, 2001 at 10:58:00AM +0200, Sebastian Brand wrote:
> it seems to me that while executing
> 
> 	X::[1,2,3],
> 	dvar_domain(X, Dom),
> 	writeln(Dom),		%%  A
> 	X ## 1,
> 	writeln(Dom).		%%  B
> 
> the value of  Dom  at both points A and B should be the same.

Actually, no.  I realise the documentation is not very explicit on this
matter, but when it says that for dvar_domain(DVar, Dom), "Dom is the domain
of the domain variable DVar", it means it literally: any change made to DVar
is reflected in Dom, and vice-versa.

In fact, the only place I found this mentioned explicitly was in the
documentation for dom_copy(+Dom1, -Dom2), which says in part, "Since the
updates are done in-place, two domain variables must not share the same
physical domain and so when defining a new variable with an existing domain,
the domain has to be copied first."

If you want to keep the state of a domain unchanged for later reference, use
dom_copy/2 to make a copy of it before doing anything which may affect the
domain of the variable.

Cheers,
Warwick
Received on Fri Jun 08 14:07:41 2001

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:07 PM GMT GMT