Path: utzoo!mnetor!uunet!husc6!uwvax!oddjob!hao!ames!pacbell!att-ih!ihnp4!inuxc!iuvax!pur-ee!uiucdcs!uiucdcsb!robison From: robison@uiucdcsb.cs.uiuc.edu Newsgroups: comp.lang.misc Subject: Re: Var scoping in Wirth-type languages Message-ID: <170500016@uiucdcsb> Date: 12 Mar 88 07:35:00 GMT References: <3949@ihlpf.ATT.COM> Lines: 32 Nf-ID: #R:ihlpf.ATT.COM:3949:uiucdcsb:170500016:000:989 Nf-From: uiucdcsb.cs.uiuc.edu!robison Mar 12 01:35:00 1988 For languages without "upward funargs" (e.g. Pascal), a global display is sufficient, and furthermore requires only one extra push/pop per procedure call. Let D[0..n] be the display registers. Then the code for entering a procedure with lexical level n is: push D[n]; D[n] := local_frame_pointer; And the code for procedure exit is: pop D[n]; return One need not copy the entire display for each procedure call. This was the Burroughs 6700's way of handling the display. I also notice that it was rediscovered in SIPLAN notices last year. I suppose the ``expensive display'' myth is related to the ``expensive procedure call'' myth. I've heard that the "static link" approach is not inefficient with a global optimizer. The "chase" becomes a common subexpression and is computed just once. Arch D. Robison University of Illinois at Urbana-Champaign CSNET: robison@UIUC.CSNET UUCP: {ihnp4,pur-ee,convex}!uiucdcs!robison ARPA: robison@B.CS.UIUC.EDU (robison@UIUC.ARPA)