🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5273

Re: Var scoping in Wirth-type languages

#5273
From: Michael Schmidt
Date: Sun, 13 Mar 1988 22:52
39 lines
1448 bytes
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
Technical Details
Message-ID: <4821@sigi.Colorado.EDU>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!hao!boulder!michael@boulder.Colorado.EDU
References: <3949@ihlpf.ATT.COM> <170500016@uiucdcsb>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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