Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!mucs!chl From: chl@cs.man.ac.uk (Charles Lindsey) Newsgroups: comp.lang.misc Subject: Re: Request For Comment About Handling Of Globals Message-ID: Date: 16 Nov 90 10:10:15 GMT References: <242@smds.UUCP> Organization: Dept. Of Comp Sci, Univ. of Manchester, UK. Lines: 23 In <242@smds.UUCP> rh@smds.UUCP (Richard Harter) writes: >The issue at hand is globals. In C there are three levels of scope -- >program global, source file global, and block. Fortran also has >three, blank common, labelled common, and subroutine/function. In >many languages with block structure inner blocks inherit variables >from outer blocks. And so on. The common (you should excuse the >expression) thread is that one wants to share access to data across >procedures. In the course of doing this one wants to avoid nasty >things like name space pollution and ensure nice things like data >hiding and restricted access. What you want is variables whose "extent" (i.e. lifetime) is forever, but whose "scope" is restricted to the bodies of the procedures which need to share them. What you want, therefore, is a modules facility, as in Modula-2 or Ada (where they are called packages) - not that those particular languages have necessarily made a perfect job of modules. My feeling is that, with a decent modules system, you can do away with classical block structure altogether.