naming domains vs. leading underscores for library routines

lcc.barry at UCLA-LOCUS.ARPA lcc.barry at UCLA-LOCUS.ARPA
Wed Aug 1 03:38:09 AEST 1984

From:            Barry Gold <lcc.barry at UCLA-LOCUS.ARPA>

This is a version of a domain naming scheme used in some LISP and LISP-like
languages.  It protects against inadvertant replacement of library routines

You add a new declaration to the language:

	domains <id> [<id>,...] ;
(the word 'domains', followed by an identifier, optionally followed by
a comma separated list of identifiers, followed by a semicolon.)  This
optional declaration may occur anywhere a function declaration could

At the beginning of a source file, the following default domains declaration
is implied:
	domains user user,lib;

External symbols defined by the source program are defined in the
domain of the first identifier.  External symbols referenced by the source
program are searched for in the optional list of identifiers.  If the
optional list is omitted, it is assumed to contain only the first identifier.

Think of the first identifier as being like the current working directory,
with the identifier list being like a search path.

Thus, the default domains declaration causes functions and variables defined
by the program to be in the domain 'user'; external references will be
searched for in the 'user' and 'lib' domains, in that order.

	extern int i;
	void fn();
is an external reference, while
	int i;
	void fn()
is a definition.

2.  Routines in the standard libraries should be compiled with the
	domain lib lib;
This will cause the library routines to always reference other library
routines, even if the user writes a function with the "same name".
If a user WANTS to replace a library routine, he can explicitly compile
it under a
	domain lib;

3.  As an alternative, the declaration domain and search list could be
provided as flags to the c compiler.  This would have the advantage of
not producing new programs that can't be compiled under the old compiler;
it sacrifices the flexibility provided by allowing multiple occurrences
of the domains declaration (e.g. in header files).

4.  This is NOT a trivial change.  It requires changing not only the compiler
and assembler, but the linker/loader and object (.o) file format.


More information about the Comp.lang.c mailing list