Re: freeze/2 and nb_setarg/3 interaction
Alan Baljeu <[email protected]> Thu, 10 Apr 2014 08:56:37 -0700 (PDT)
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
I'm not convinced SWI is wrong here. I suspect in your 'broken' case that the second writeln is actually writing [H|T]. It also seems odd that given X is already [H|T] you would attempt setarg(1,X,H), which is a no-op. If instead you initialized X=[_|_] the code would make a little more sense. In fact, it works. In other words, freeze isn't the problem. Alan Baljeu ________________________________ From: Michael Hendricks <[email protected]> To: Prolog mailing list <[email protected]>; Jan Wielemaker <[email protected]> Sent: Thursday, April 10, 2014 10:54:17 AM Subject: Re: [SWIPL] freeze/2 and nb_setarg/3 interaction I spent the morning looking through pl-prims.c and pl-attvar.c to debug this. My untrained eye didn't see any obvious problems. Jan, what's the best way for me to debug something like this? Thanks. -- Michael On Wed, Apr 9, 2014 at 8:58 AM, Michael Hendricks <[email protected]> wrote: > freeze/2 and nb_setarg/3 seem not to work together. Consider this example: > > > correct :- > X=[_|_], > ( nb_setarg(1,X, a), > nb_setarg(2,X, [b,c]), > writeln(X), > fail > ; writeln(X) > ). > > broken :- > X=[H|T], > freeze(H,nb_setarg(1,X,H)), > freeze(T,nb_setarg(2,X,T)), > ( H = a, > T = [b,c], > writeln(X), > fail > ; writeln(X) > ). > > > ?- correct. > [a,b,c] > [a,b,c] > true. > > ?- broken. > [a,b,c] > [_G1009|_G1010] > true. > > Is that expected behavior? > > -- > Michael > -------------- next part -------------- HTML attachment scrubbed and removed _______________________________________________ SWI-Prolog mailing list [email protected] https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog -------------- next part -------------- HTML attachment scrubbed and removed