Path: utzoo!attcan!utgpu!watserv1!vlsi!dougren From: dougren@vlsi.waterloo.edu (Douglas Renaux) Newsgroups: comp.lang.prolog Subject: Re: Who allocates space for perm vars on stack ? Message-ID: <1990Sep17.204438.15278@vlsi.waterloo.edu> Date: 17 Sep 90 20:44:38 GMT References: <10942@uswat.UUCP> <398@cancol.canberra.edu.au> Organization: University of Waterloo Lines: 47 In article <398@cancol.canberra.edu.au> jan@cancol.canberra.edu.au (Jan Newmarch) writes: > > > > >In article <10942@uswat.UUCP>, naim@uswat.uswest.com (Naim Abdullah) writes: >> Research Labs). One of the things that I am puzzled about is which >> WAM instruction is responsible for storing the permanent variables >> in the environment when a new rule is called. >> >> The situation is illustrated by the following: >> >> foo(args) :- ...., bar(args),.... >> >> This is translated to: >> >> foo: allocate >> get args of foo >> ..code for predicates before bar... >> put args of bar >> call bar/arity, N >> ...code for predicates after bar... >> proceed >> >> bar: allocate >> get args of bar >> ...code for bar's body.. >> proceed >> >> .................... So my question is which instruction allocates the space >> for bar's permanent variables ? > >.... >If it does have some, then they have space created for them when you first come >across them, by e.g. a "put_variable Y". Subgoals in the body of bar will > >| Jan Newmarch |:-)| ACSnet: jan@cancol.oz >| Info. Sciences & Eng.|___| ARPA: jan%cancol.oz.au@uunet.uu.net Space for a permanent variable (a variable in the environment) is never created by a "put_variable Y". Only "allocate" reserves (creates) space in the local stack (in an environment) for permanent variables. However, "allocate" only reserves space, it has to be initialized later on by an instruction as: "get_variable Yi,An", "get_value Yi,An", "put_varia- ble Yi,An". Douglas Renaux dougren@vlsi.waterloo.edu