copy_term(AttrVar, Var, Pred)
where Pred is a goal that reinstantiates Var to
a copy o AttrVar.
In ECLiPse copy_term/3 is defined in a different way.
Pred is a list of lists and not a goal.
I would like to have a possibility to assert attributed
variables. In SISCStus one could use a following code:
copy_term(AttrVar, Var, Pred), asserta(var(Id, Var, Pred))
What code should I use in ECLiPSe to achieve the same
result?
So far I have used:
asserta(var(Id, [AttrVar]))
but I do not know if it is portable. Using copy_term
in ECLiPSe does not make much sense (contrary
to SICStus and SWI).
I will be grateful for any comments that would
clarify those issues. What standard says?
Best regards
PS
I have problems sending this on ECLiPSe's mailing list
so I decided to post it here.
--
[ Wit Jakuczun <W.Jakuczun [at] wlogsolutions.com> ]
[ WLOG Solutions http://www.wlogsolutions.com ]
It seems that "Standard Book" defines only copy_term/2
A.L.
What do you really want?
Do you want a table to access your variables by name?
Do you want to save domains across backtracking?
Do you want to duplicate parts of the constraint store?
...
> In SISCStus one could use a following code:
> copy_term(AttrVar, Var, Pred), asserta(var(Id, Var, Pred))
>
> What code should I use in ECLiPSe to achieve the same
> result?
> So far I have used:
>
> asserta(var(Id, [AttrVar]))
That looks like you want something like
copy_term(AttrVar, Copy), store_set(var, Id, Copy)
ECLiPSe's copy_term/2 will copy a sensible subset of the
attribute information, like the domains in case of a domain
variable. You can then store this copy and save it across
backtracking. However, if you know anyway what you want to
save across backtracking, e.g. the domain, you can store a
representation of the domain (e.g. an interval list)
instead of an attributed variable, and on retrieval make
a new variable from that information.
>
> but I do not know if it is portable. Using copy_term
> in ECLiPSe does not make much sense (contrary
> to SICStus and SWI).
>
> I will be grateful for any comments that would
> clarify those issues. What standard says?
There is no standard for these Prolog extensions.
>
>
> Best regards
> PS
> I have problems sending this on ECLiPSe's mailing list
> so I decided to post it here.
It's hosted on Sourceforge, which wasn't very responsive today...
-- Joachim
> Wit Jakuczun wrote:
> > Hi,
> > I have a question regarding copy_term/3.
> > In SICStus and SWI it works like that:
> >
> > copy_term(AttrVar, Var, Pred)
> >
> > where Pred is a goal that reinstantiates Var to
> > a copy o AttrVar.
> >
> > In ECLiPse copy_term/3 is defined in a different way.
> > Pred is a list of lists and not a goal.
> >
> > I would like to have a possibility to assert attributed
> > variables.
>
> What do you really want?
> Do you want a table to access your variables by name?
> Do you want to save domains across backtracking?
> Do you want to duplicate parts of the constraint store?
> ...
>
I do not know apriori what clp model will be
built (which variables in which constraints).
I build such model in an iterative way. I add
variables as optimization process proceeds
(like in TSP you get a new city to be visited).
Moreover I am curious :).
> > In SISCStus one could use a following code:
> > copy_term(AttrVar, Var, Pred), asserta(var(Id, Var, Pred))
> >
> > What code should I use in ECLiPSe to achieve the same
> > result?
> > So far I have used:
> >
> > asserta(var(Id, [AttrVar]))
>
> That looks like you want something like
>
> copy_term(AttrVar, Copy), store_set(var, Id, Copy)
>
Thanks, I will check that.
> ECLiPSe's copy_term/2 will copy a sensible subset of the
> attribute information, like the domains in case of a domain
> variable. You can then store this copy and save it across
> backtracking. However, if you know anyway what you want to
> save across backtracking, e.g. the domain, you can store a
> representation of the domain (e.g. an interval list)
> instead of an attributed variable, and on retrieval make
> a new variable from that information.
>
Thanks, that is practically what I need. Saving domains
is what I want. I think also that it is the most
portable way as it should work for all variables.
I do not know what whould be efficiency,though.
> > I will be grateful for any comments that would
> > clarify those issues. What standard says?
>
> There is no standard for these Prolog extensions.
>
Ok, I understand.
> > Best regards
> > PS
> > I have problems sending this on ECLiPSe's mailing list
> > so I decided to post it here.
>
> It's hosted on Sourceforge, which wasn't very responsive today...
>
Well it continuously sends back my posts saying that
there are problems with verification. I cannot even
send help message to the owner of the list :).
Best regards