Re: [eclipse-clp-users] var vs. free

From: Kish Shen <kisshen_at_...5...>
Date: Tue, 25 Jan 2011 22:27:20 +0000
On 25/01/2011 10:31, Ulrich Scholz wrote:
> Dear Joachim,
>
> thanks for pointing out the difference between var and free.  I'll try to
> keep it in mind.
>
> However, the code my example is based on seems to be a case of a valid use
> of free/1: After the call, the first argument is a solver variable.  If
> called with a free, unattributed variable, a new solver variable is created.
> Otherwise, this step is skipped.

I am not sure from what you wrote if you are dealing with the case where 
an attributed variable is not a solver variable. Normally you would need 
to turn such variables into solver variables as well.

If your 'solver' is a library solver (such as ic), then you probably 
should test if the first argument is a variable or not (with var/1),
and then if a variable is a solver variable (is_solver_var/1 for ic) or 
not, so that a non-solver variable can be turned into a solver variable.

If you are developing your own solver, using your own attribute to do 
so, you can use free/1 to decide if you need to create an attributed 
variable. If this is what you are doing, then I assume you have a clause 
after the clause with free/1 to catch the case where you need to convert 
an existing attributed variable into your solver variable
(as shown in the documentation for free/1 Joachim pointed to).

Cheers,

Kish

-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Tue Jan 25 2011 - 22:27:53 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST