[racket] [bug?] Racklog cut differs from Prolog cut

From: Erik Dominikus (erik.dominikus71 at gmail.com)
Date: Thu Aug 16 00:28:32 EDT 2012

Yes, sorry, it was a honest mistake in my part (late night coding
session :P), but the bug is still there when that cut is removed. And
yes, that was what Matthias meant.


Allow me to copy a part of the SWI Prolog documentation, if it may be of
any help:

?- help(!).
!                                                                 [ISO]
    Cut.    Discard choice  points of  parent frame  and frames  created
    after the parent frame.   As of SWI-Prolog 3.3, the semantics of the
    cut  are compliant with  the ISO  standard.   This implies that  the
    cut  is transparent to ;/2, ->/2  and *->/2.  Cuts appearing  in the
    condition  part of ->/2 and  *->/2 as well  as in \+/1 are local  to
    the condition.

             t1 :- (a, !, fail ; b).        % cuts a/0 and t1/0
             t2 :- (a -> b, !  ; c).        % cuts b/0 and t2/0
             t3 :- call((a, !, fail ; b)).  % cuts a/0
             t4 :- \+(a, !, fail ; b).      % cuts a/0


The problem seems to be in the scope of the cut. Racklog cut seems to
cross %rel boundary whereas Prolog cut does not. Maybe Racklog has a
different concept of 'parent frame'? Maybe Racklog cut was meant to be
lexically scoped, but turns out to be dynamically scoped? Just a wild
guess though...

%not and %if-then-else might also be affected by this bug.


(FYI, if a reply is needed, expect it to be late as I'll be on holiday
until Aug 27.) 


Thank you.



On Mon, 2012-08-13 at 16:58 -0400, Ryan Culpepper wrote:
> On 08/13/2012 04:41 PM, Marco Alberti wrote:
> > Erik,
> >
> > On Sun, 12 Aug 2012 12:32:53 +0700, Erik Dominikus wrote:
> >
> >
> >> (define %a
> >>    (%rel (x)
> >>          ((x) (%b x) !)
> >>          ((x) (%c x)) ))
> >
> > the cut in the first clause is not there in the Prolog version; hence the
> > different behaviour.
> 
> The problem exists even if you remove this cut. The other cut (in %b) is 
> still behaving incorrectly.
> 
> (I assume that's what Matthias meant in his recent response.)
> 
> Ryan
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



Posted on the users mailing list.