🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5264

Re: Var scoping in Wirth-type languages

#5264
From: Erland Sommarskog
Date: Fri, 11 Mar 1988 21:22
33 lines
2008 bytes
00704a-Liber,N.J. (nevin1@ihlpf.UUCP) writes:
>Globals, unless implemented with the optimization I'm going to state later,
>are much less efficient than using locals!  If I didn't make that point
>clear in my last posting, please excuse me.
>
>For every level deep that a variable is used after it is declared, one
>climb up the static chain of activation records (I think this is the right

Nevin continues with an example, which I have deleted.

Yes, that kind of globals are slower, for sure. I was thinking of 
variables declared on module/program level. They are allocated to a 
fix adress, and there very quick to access. In the case I quoted, I 
think they were global on process level. I don't know the details of 
the implementation, but it seems likely that time to access a process 
variable and local variable are about the same.

>In addition to the standard var declarations, one should be allowed to
>declare a variable 'static' (to steal from C).  The scoping would be the
>...
>Note:  This optimization can already be done on variables that can be
>determined not to be used recursively and are referenced at a level deeper
>then they are declared.  However, by adding explicit static declarations,
>the programmer has much more flexibility.  Comments??

It seems to me that compiler should have the headache to decide which
variables should be static, not the programmer. 

-- 
Erland Sommarskog       
ENEA Data, Stockholm        
sommar@enea.UUCP           "Si tu crois l'amour tabou...
                            Regarde bien, les yeux d'un fou!!!" -- Ange
Technical Details
Message-ID: <2832@enea.se>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!enea!sommar
References: <2791@enea.se> <3949@ihlpf.ATT.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!enea!sommar
From: sommar@enea.se (Erland Sommarskog)
Newsgroups: comp.lang.misc
Subject: Re: Var scoping in Wirth-type languages
Message-ID: <2832@enea.se>
Date: 11 Mar 88 21:22:24 GMT
References: <2791@enea.se> <3949@ihlpf.ATT.COM>
Reply-To: sommar@enea.UUCP(Erland Sommarskog)
Followup-To: comp.lang.misc
Organization: ENEA DATA AB, Sweden
Lines: 33