Path: utzoo!mnetor!uunet!husc6!hao!boulder!michael@boulder.Colorado.EDU From: michael@boulder.Colorado.EDU (Michael Schmidt) Newsgroups: comp.lang.misc Subject: Re: Var scoping in Wirth-type languages Message-ID: <4821@sigi.Colorado.EDU> Date: 13 Mar 88 22:52:35 GMT References: <3949@ihlpf.ATT.COM> <170500016@uiucdcsb> Sender: news@sigi.Colorado.EDU Reply-To: michael@boulder.Colorado.EDU (Michael Schmidt) Organization: Uni-GH Paderborn, FB17/Informatik Lines: 36 In-reply-to: robison@uiucdcsb.cs.uiuc.edu Posting-Front-End: Gnews 1.1 In article <170500016@uiucdcsb>, robison@uiucdcsb writes: >For languages without "upward funargs" (e.g. Pascal), a global display >is sufficient, and furthermore requires only one extra push/pop per >procedure call. No! Cosider the following program: { LAST EDIT: Sat Mar 12 12:27:35 MST 1988 by Michael Schmidt (michael) } PROGRAM funparm (input, output); VAR FirstTime : Boolean; PROCEDURE f(procedure x); VAR j: integer; BEGIN x END; {f} PROCEDURE g(); VAR i: integer; PROCEDURE h(); BEGIN if FirstTime then begin FirstTime := false; f(h) end else writeln(i) END; {h} BEGIN h END; {g} BEGIN END. {funparm} At execution of 'h', you will have the frame of 'f' in the display for level 1 instead of the frame of 'g'! And you will get the value of 'j' instead of the value of 'i'! Right? Michael