Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site datagen.UUCP Path: utzoo!linus!philabs!cmcl2!rocky2!datagen!mrm From: mrm@datagen.UUCP Newsgroups: net.lang Subject: Re: I/O operations in programming languages Message-ID: <16@datagen.UUCP> Date: Wed, 31-Aug-83 09:43:15 EDT Article-I.D.: datagen.16 Posted: Wed Aug 31 09:43:15 1983 Date-Received: Thu, 1-Sep-83 21:30:56 EDT References: <666@mit-eddie.UUCP>, <110@csd1.UUCP>, <1796@allegra.UUCP> Organization: Data General Dist. Systems, Westborough, MA Lines: 42 C does not have I/O built into the language per-se, since the compiler proper does not recognize calls to printf et. all. Rather it interprets them as normal function calls (and/or macro replacements). The user is free to write his/her own `printf' that does input instead of output or what have you. Also C stdio is not completely portable since a header file could change a declaration from `int' to `long' on any given machine and the format strings must be changed manually from "%d" to "%ld". On a 16 bit machine this would produce incorrect results, whereas on a 32 bit machine it would produce correct results. Since the I/O is not builtin, the compiler cannot tell the I/O system the type of the variables through dope vectors, and the poor user is left to manage as best s/he can. This discussion also brings to mind that this is a good case for bringing back the old "%r" format. For those of you who don't know, %r interpretted the next argument as a nested format, thus you could make one macro be the standard format for any given type, which you might print out in several different places. For example: #ifdef PDP11 typedef long type; #define FORMAT "%ld" #endif #ifdef VAX typedef int type; #define FORMAT "%d" #endif type a; ... printf( "a is %r\n", FORMAT, a ); (allegra,ittvax)!datagen!mrm