Related articles |
---|
[7 earlier articles] |
Re: PCODE Interpereters 101 sam@cogent.ca (Sam Roberts) (1999-02-12) |
Re: PCODE Interpereters 101 kevin.b.smith@intel.com (Kevin B. Smith) (1999-02-15) |
Re: PCODE Interpereters 101 cfc@world.std.com (Chris F Clark) (1999-02-15) |
Re: PCODE Interpereters 101 toring@inet.uni2.dk (Torben Ring) (1999-02-18) |
Re: PCODE Interpereters 101 aduncan@cs.ucsb.edu (aduncan) (1999-02-21) |
Re: PCODE Interpereters 101 albaugh@agames.com (1999-02-24) |
Re: PCODE Interpereters 101 Scott.Daniels@Acm.Org (Scott.David.Daniels) (1999-03-02) |
From: | "Scott.David.Daniels" <Scott.Daniels@Acm.Org> |
Newsgroups: | comp.compilers |
Date: | 2 Mar 1999 14:12:06 -0500 |
Organization: | Northwest Link |
References: | 99-01-079 99-01-117 99-02-094 99-02-110 99-02-116 |
Keywords: | Pascal |
Dynamic links are, I believe necessary for languages where nested
declarations occur and up-level access is allowed. An example that is
tough (read: I think impossible) to execute properly without displays
is:
begin
string procedure foo( integer depth, string arg, string procedure
takeNote(string) )
{
string procedure parenthesized( string inArg )
{
return "(" & depth & ": " arg & " :" & inArg & ")";
}
return (if 0 = depth then takeNote( arg )
eif 2 = depth then foo( depth-1, "<" & arg & ">", parenthesized )
else foo( depth-1, "[" & arg & "]", parenthesized )
}
string procedure braces( string inArg ) { return "{" & arg & "}"; }
foo( 4, "x", braces );
end
= foo(3, [x], braces)
= foo(2, [[x]], braces)
= foo(1, <[[x]]>, paren'2)
= foo(0, [<[[x]]>], paren'2)
= (2: [<[[x]]>], [[x]])
Where this comes up:
1) implementing an interpreter with stack allocation via recursive calls
to the interpreter.
2) implementing unification.
-Scott David Daniels
Scott.Daniels@Acm.Org
Return to the
comp.compilers page.
Search the
comp.compilers archives again.