[comp.misc] 'File' name scopes

exspes@gdr.bath.ac.uk (P E Smee) (12/05/89)

Charlie Martin asks:
> (Does anyone know of any other languages than C -- other than C++ etc --
> that have this file scope mechanism?)

(Sorry about that, another 'unreplyable'.)  PL/1 offers an
approximately equivalent mechanism for creating variables and
subroutines/functions which are freely shareable by a limited number of
your functions without having to be made globally accessible.  The
effect is obtained by use of 'internal' subroutines/functions, and
multiple entrypoints (if the outside world needs more than one way to
get in).  The precise mechanism is both semantically and syntactically
different from that of C, but the ultimate effects are much the same.

Tradeoffs to be considered are similar to those involved in deciding
whether or not to group several C-functions within one source file.
You'd like shared variables to be hidden from the rest of the world,
but you don't want an individual source file to grow unmanageably
large.
-- 
 Paul Smee, Univ. of Bristol Comp. Centre, Bristol BS8 1TW (Tel +44 272 303132)
 Smee@bristol.ac.uk   :-)   (..!uunet!ukc!gdr.bath.ac.uk!exspes if you HAVE to)

nick@lfcs.ed.ac.uk (Nick Rothwell) (12/06/89)

In article <1989Dec5.104848.12081@gdt.bath.ac.uk>, exspes@gdr (P E Smee) writes:
>
>Charlie Martin asks:
>> (Does anyone know of any other languages than C -- other than C++ etc --
>> that have this file scope mechanism?)
>
>(Sorry about that, another 'unreplyable'.)  PL/1 offers an
>approximately equivalent mechanism for creating variables and
>subroutines/functions which are freely shareable by a limited number of
>your functions without having to be made globally accessible.

Do you mean this kind of thing? (Standard ML):

	local
	  type myType = ...
	  val x: myType = ...
	  fun fred(...) = ...
	  and jim(...) = ...
	in
	  fun joe(...) = ...fred ... jim ... x ... myType ...
	  fun jack(...) = ...fred ... jim ... x ... myType ...
	end
Nick Rothwell,	Laboratory for Foundations of Computer Science, Edinburgh.
		nick@lfcs.ed.ac.uk    <Atlantic Ocean>!mcvax!ukc!lfcs!nick
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
           "You're gonna jump!?"       "No, Al. I'm gonna FLY!"