From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,2afd440a210c7fb0 X-Google-Attributes: gidf7344,public X-Google-Thread: 1014db,6bdc5c27a0dec527 X-Google-Attributes: gid1014db,public X-Google-Thread: 1164f8,df8a3dc583bf1f5f X-Google-Attributes: gid1164f8,public From: JF Mezei Subject: Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Date: 1998/08/30 Message-ID: <35EA0E22.C59E9476@videotron.ca>#1/1 X-Deja-AN: 386302318 Content-Transfer-Encoding: 7bit References: <0095000017115526000002L062*@MHS> <6s910k$2bo$1@Starbase.NeoSoft.COM> <35e833be.0@news.wizvax.net> <6sac4v$4ti$1@Starbase.NeoSoft.COM> <35e8f9d7.0@news.wizvax.net> <904480575snz@genesis.demon.co.uk> <35E9E464.AD231759@videotron.ca> <6scur7$qtk@bgtnsc02.worldnet.att.net> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@videotron.net X-Trace: weber.videotron.net 904530993 207.96.132.85 (Sun, 30 Aug 1998 22:36:33 EDT) MIME-Version: 1.0 NNTP-Posting-Date: Sun, 30 Aug 1998 22:36:33 EDT Newsgroups: comp.os.vms,comp.sys.dec,comp.lang.c > >1- The list of reserved words does not include function calls. > > Yes it does. I suggest you check Kernigham and Ritchie, 1978 edition. Appendix A (starts at page 214) Or better yet, the official list of reserved words at page 180 (again appendix A). > >The compiler has no idea what "printf" is supposed to do. > > A compiler is allowed to know exactly how printf is supposed to > function. Nop, because the compiler does not know to what library the object module will eventually be linked with. Case in point: on a VAX-VMS, you can link against the VAXCRTL or DECCRTL libraries, which, while similar, have significant differences. Obviously, if you work on a system where the linker is integrated in the compiler, there may be some optimisations that are permissible if the compiler-linker knows you will link against that supplied libraries. But that is an implementation "derivative", not part of the language. > For example, having two printfs to deal with invokes undefined- > behavoir. Some linkers allow this to happen through the use of "search order" and a switch to allow this. Furthermore, the compiler has no idea that during the link operation, instead of supplying the standard run-time as a library, you will supply a different library. Quoting from K&R, page 1: "Finally, C itself provides no input-output facilities: there are no READ or WRITE statements, and no wired-in file access methods. All these higher-level mechanisms *MUST* be provided by explicitely called functions." (emphasis on MUST is mine). By that definition alone, a compiler which assumes a certain behaviour for printf and translates it to inline code instead of a call to the printf routine in a library would not adhere to the C standards. Must be a Microsoft compiler. > Also, a macro may get exapanded or a function called based on > how it's being used. That is part of the language. Disagree. If you do not have a #include that defines the macro, the use of your "keyword" will result in a function call to be resolved by the linker. If you have a #include with a #define for your keyword, that keyword will get expanded during the pre-processor stage, prior to actual compilation. On the good old VAXC, the lack of #include would result in references to isnum(char) being compiled as a function call. When you included string.h, isnum(char) would be expanded in macro which did the same job (but more efficiently). This varies from implementation to implementation. And it is not part of the actual C language. And you should note that it is not the compiler which generates the "inline code" but rather the pre-processor which converts a keyword into a list of C language statements which are then compiled as if you had typed them in.