[net.lang.c] naming domains vs. leading underscores for library routines

lcc.barry@UCLA-LOCUS.ARPA (07/31/84)

From:            Barry Gold <lcc.barry@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
by users, but it WON'T BREAK EXISTING PROGRAMS.

You add a new declaration to the language:

Syntax:
	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
occur.

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

Semantics:
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.

Notes:
1.
	extern int i;
or
	void fn();
is an external reference, while
	int i;
or
	void fn()
	{...}
is a definition.

2.  Routines in the standard libraries should be compiled with the
declaration:
	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;
declaration.

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.

barry