Machine specific predefined names
Vincent Hatem
gak at mhuxm.UUCP
Thu Mar 3 09:15:40 AEST 1988
In article <7387 at brl-smoke.ARPA>, gwyn at brl-smoke.UUCP writes:
> In article <265 at aiva.ed.ac.uk> richard at uk.ac.ed.aiva (Richard Tobin) writes:
> >It would also be nice if a user could easily replace the open() function
> >(for example) with one of their own that could call the original one.
>
> I disagree strongly with this. The application writer has no way of knowing
> what the specific internal library semantics are, making it likely that his
> meddling would break the behavior of some of the standard library routines.
>
> For example, my System V emulation package on a BRL/JHU PDP-11 UNIX kept
> track of open file descriptors internally. Interception of _open() by an
> application that was unaware of this could have led to erroneous operation.
Once upon a time (not long ago) I re-wrote (not alone) the link library for
Modula-2 on the Sun. We were writing a system in M2 and needed to have a truely
*portable* library.
Anyway, I thought that Modula-2's ability to re-use function names *very*
useful. By changing the IMPORT statement, you could change the I/O system
that you were using. By using an Object-Oriented Modular design in the library,
you could NOT mix implementations - each module contains a complete set of
functions to act upon the file object - ie: open(), close(), read(), write().
Since you cannot include unqualified IMPORTs of two modules containing the
same function names, the problem of getting the wrong read() is nonexistant.
Since the higher-level functions (functions such as printf()) eventually use
read/write, etc., and all the modules use the same parameters for the same
functions (ie: the open() in every module takes the same parameters), the
functions (modules) may be interchanged.
I think that C could learn a lot from Modula-2. It may look like Pascal, but
you can do things in Modula-2 that you can't even do in C! (such as set your
registers without resorting to assembler, among others)
--
Vincent Hatem
AT&T International, International Systems Operations, UNIX Technical Support
Telefon: (201) 953-8030
Please send all e-mail to: ihnp4!atti01!vch
More information about the Comp.lang.c
mailing list