Re: Strange problem with dom/2 pred of fd constraint solver

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 01 Mar 2002 02:50:03 PM GMT
Message-ID: <3C7F951B.E204D86F@icparc.ic.ac.uk>
Paulo Moura wrote:
> 
> Hi Joachim!
> 
> A Logtalk user found a strange problem while trying to call the dom/2
> predicate defined in the Eclipse FD constraint solver. The problem
> arises when we try to compile this simple object:
> 
> :- object(foobar).
> 
>         test:-
>                 X::[1, 10],
>                 {fd:dom(X, List)}.
> 
> :- end_object.
> 
> In Logtalk, the {}/1 control construct is used to bypass the Logtalk
> pre-processor/compiler. So, the compilation of the test/0 predicate
> should contain the call fd:dom(X, List). However this only seams to work
> for any fd predicate except dom/2! Is there anything special about this
> predicate that may helps us understand the problem?


I had a look and it turns out that the functor dom/2 has a portray-
transformation attached, in order to print domains more nicely.
A portray-transformation is a transformation that is applied
whenever a term with that functor is printed, e.g.

[eclipse 1]: lib(fd).
[eclipse 2]: write(dom([3],1)).
3

In the logtalk sources, it looks like you are using
write_term(Term, [quoted(true)]) to print the result of the
compilation. Unfortunately, this does not suppress the
transformation from being made:

[eclipse 2]: lib(iso).
[eclipse 5]: write_term(dom([3],1), [quoted(true)]).
3

You can suppress it currently by using ignore_ops:

[eclipse 4]:  write_term(dom([3],1), [ignore_ops(true)]).
dom(.(3, []), 1)

This might be considered a bug in our lib(iso). Probably the
transformations should be suppressed by default in write_term
and only enabled by the portrayed(true) option?

You can also use writeq, which does exactly the right thing:

[eclipse 7]: writeq(dom([3],1)).
dom([3], 1)


As a quick fix, your user can erase the transformation after
loading fd:

:- lib(fd).
:- erase_macro(dom/2, [write]).


Cheers,
Joachim
-- 
 Joachim Schimpf              /             phone: +44 20 7594 8187
 IC-Parc, Imperial College   /            mailto:J.Schimpf@ic.ac.uk
 London SW7 2AZ, UK         /    http://www.icparc.ic.ac.uk/eclipse
Received on Fri Mar 01 14:50:04 2002

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