[net.unix] Qualified Names mean you don't break the C Library

idallen@watmath.UUCP (07/24/84)

If you don't have unique names for things like printf and getchar,
names that are identifiable so that no programmer will use them by
mistake, then you can never have one C Library routine call another C
Library routine, because the called routine might have been
accidentally redefined to do something that the Library doesn't
expect.  If I write a do-nothing function called malloc() and put it in
my program, every C Library routine that uses malloc() breaks.  This is
a bad thing.  I do not want to have to learn all the names of every
routine that ever is, was, or will be put in the C Library.  I want to
be told "if you never use an external name like such-and-so, you will
never break the library".  The C Library should be calling a special
internal name for malloc(); not a simple external name that you
are likely to stumble across.  If you *really* want to redefine the
Library's malloc, you redefine the internal name -- but, it is very
clear (by the form of the name) that you are doing something special.

The B Programming Language has reserved identifiers containing a
period for internal system use.  My programs call printf() -- the
library always calls .prntf().  If I never use an external with a
period in it, I never mess up the library.

Of course, this only works like this because most programs are
two-tiered -- my source, and the library.  When you start to apply
this to different libraries, each needing its own convention for
identifiers...  argh.
-- 
        -IAN!  (Ian! D. Allen)      University of Waterloo

mark@elsie.UUCP (07/26/84)

<>
One way to avoid collision between your own subroutine names and those that
may be used by the C libraries is to declare all routines that are used only
in a single source file to be static. Thus if I want to write my own malloc,
I write:
	static malloc(size)
	unsigned	size;
	{
	...
	}
This will (should) not interfere with any malloc's used by the library. Of
course if I want to this malloc from other files of a multi-file source, I
can't use static so I'd better change the name.

-- 
Mark J. Miller
NIH/NCI/DCE/LEC
UUCP:	decvax!harpo!seismo!umcp-cs!elsie!mark
Phone:	(301) 496-5688