5 Oct 12:07
Re: 5.7.X : problem with attributed variables and memberchk ?
From: Jan Wielemaker <J.Wielemaker <at> uva.nl>
Subject: Re: 5.7.X : problem with attributed variables and memberchk ?
Newsgroups: gmane.comp.ai.prolog.swi
Date: 2008-10-05 10:07:53 GMT
Subject: Re: 5.7.X : problem with attributed variables and memberchk ?
Newsgroups: gmane.comp.ai.prolog.swi
Date: 2008-10-05 10:07:53 GMT
On Saturday 04 October 2008 22:08:59 Bart Demoen wrote: > > ?- A in 0..5, B in 6..7, memberchk(A, [B, C]). > > false. > > > > > > Shouldn't the last one return : > > A = C, > > C in 0..5, > > B in 6..7. > > > > ? > > First a look at: > > ?- help(memberchk). > memberchk(?Elem, +List) > Equivalent to member/2, but leaves no choice point. > > This is enough to answer your question: yes, you are correct about > your expectation. > > In fact, the implementation of pl_memberchk in pl-list.c cuts the > choicepoint before executing woken goals. It is a bit tricky to get > this correct (from within C), but currently it doesn't deliver what > the manual promises I think. If memchk/2 is written in Prolog, you get > what you expect. Thanks Bart. There is a call foreignWakeup() that executes delayed calls and can be used (only) at places where C code is about to do something that is effectively a cut. Also used by (e.g.) \=. Fixed in 5.6.x and merged into 5.7.x. memberchk/2 is now getting a bit complicated and hopefully 5.7.x itself will get fast enough someday to avoid the desire to write memberchk in C. Setup and exit are a bit slower. Luckily the iteration over non-unifying elements without attributes remains the same. > How did you find this bug ? I'm still surprised how obvious bugs remain unnoticed for years while at the same time there are reports on very weird bugs. --- Jan _______________________________________________ SWI-Prolog mailing list SWI-Prolog <at> iai.uni-bonn.de https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
. Setup and exit are a bit slower. Luckily the iteration over
non-unifying elements without attributes remains the same.
> How did you find this bug ?
I'm still surprised how obvious bugs remain unnoticed for years while
at the same time there are reports on very weird bugs.
--- Jan
_______________________________________________
SWI-Prolog mailing list
SWI-Prolog <at> iai.uni-bonn.de
RSS Feed