Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ptsfa!pacbell!att-ih!ihnp4!homxb!mhuxt!mhuxu!mhuxi!mhuxm!gak From: gak@mhuxm.UUCP (Vincent Hatem) Newsgroups: comp.lang.c Subject: Re: Machine specific predefined names Message-ID: <722@mhuxm.UUCP> Date: 2 Mar 88 23:15:40 GMT References: <1988Feb17.115402.12739@light.uucp> <7387@brl-smoke.ARPA> Organization: AT&T Bell Laboratories, Murray Hill Lines: 38 Summary: think again... In article <7387@brl-smoke.ARPA>, gwyn@brl-smoke.UUCP writes: > In article <265@aiva.ed.ac.uk> richard@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