🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Sanjeev Kumar Thu, 04 Aug 1988 06:26
A question on the compilation of Prolog.
#1
Author: Sanjeev Kumar
Date: Thu, 04 Aug 1988 06:26
37 lines
1976 bytes
I have a doubt to clarify from an example that is given in the book
mentioned above. This is an example on pages 470-471. The example has
been given in the context of trimming environments for a clause. The whole
example and the insruction in doubt are as follows: 
(WPE is another name for WAM)

Prolog Source 			WPE Machine Code
p(A,D) :-		     p: alloc
	q(A,B), r(B,C),		getVar	r2, 2	% D is first in frame
	s(C,D).			putVar	r2, 4	% B is last in frame
				call	q:, 5	% space for D,C,B
				putUVal	r1, 4	% B to r1
				putVar	r2, 3	% C is second in frame
				call	r:, 4	% space for D,C
	/*****/ ---------->     putVal	r1, 3	% C to r1
				putVal	r2, 2	% D to r2
				dealloc
				exec	s:


 My objection is to the instruction marked by /*****/. I think it
should be "putUVal r1, 3" for the same reason as putUVal has been
used for B. C might still be unbound after the call to r, and since
we are deallocating the frame for the clause before the call to s:, C 
becomes unsafe.

All explanations are welcome.

Apart from the doubt mentioned above, I found the section on the WAM
(#11.8) very useful and well written.

Sanjeev Kumar.
-- 
Sanjeev Kumar. ( skumar@paul.rutgers.edu ) 
Phone: Off. (201)932-3766, Res. (201)878-1841.
Dept. of Computer Science, RUTGERS, New Brunswick, NJ08903.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads