Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!vu0310 From: vu0310@bingvaxu.cc.binghamton.edu (R. Kym Horsell) Newsgroups: comp.lang.prolog Subject: Re: Arrays in Prolog Message-ID: <3920@bingvaxu.cc.binghamton.edu> Date: 30 Aug 90 20:34:36 GMT References: <90239.175243SCHMIED@DB0TUI11.BITNET> <3899@bingvaxu.cc.binghamton.edu> <1990Aug28.065353.13951@sics.se> <3904@bingvaxu.cc.binghamton.edu> <1162@cluster.cs.su.oz> <3906@bingvaxu.cc.binghamton.edu> <3321@skye.ed.ac.uk> Reply-To: vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) Organization: SUNY Binghamton, NY Lines: 36 In article <3321@skye.ed.ac.uk> richard@aiai.UUCP (Richard Tobin) writes: >I have never used setarg, but it seems you are confusing two things: >the ability to change the value of an instantiated variable, and the >ability to preserve the value of a variable when backtracking. In my original post my point was that setarg/3 as implemented in the compiler I'm working on works as follows (a bit hard to write this in Prolog, of course): setarg(Index,Term,Arg) :- arg(Index,Term,OldArg), /* save "OldArg" somewhere */, /* destructively change argument number ``Index'' of ``Term'' to ``Arg'' via some dirty internal mechanism */ ; /* destructuvely change argument number ``Index'' of ``Term'' to ``OldArg'' via some dirty internal mechanism */. Thus I am perfectly correct to say a cut after *my* setarg/3 will lose a backtrack point (note the ;/2) and the dirty internal stuff that changes the relevant arg *back* to its original value is lost. If we therefore use *my* setarg/3 information *can* be transferred from one disjunctive branch to another by means other than assert/retract. I have no intention of *defending* the implementation of such a dirty mechanism, which I realize destroys both the *forward* and even *backward* declarative reading of Prolog programs in which it is included. I hope this post saves some bandwidth in the long run. -Kym Horsell