From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,971aa11c293c3db1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-03 23:04:59 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn1feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <3B59CD72@MailAndNews.com> <9j749o$lmp$7@news.tpi.pl> <9j9n9v$djt$1@news.tpi.pl> Subject: Re: Ada The Best Language? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Sat, 04 Aug 2001 06:04:58 GMT NNTP-Posting-Host: 12.89.143.249 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 996905098 12.89.143.249 (Sat, 04 Aug 2001 06:04:58 GMT) NNTP-Posting-Date: Sat, 04 Aug 2001 06:04:58 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:11282 Date: 2001-08-04T06:04:58+00:00 List-Id: David C. Hoos wrote : > > ----- Original Message ----- > From: "Tomasz Wegrzanowski" > Newsgroups: comp.lang.ada > To: > Sent: Friday, July 20, 2001 11:46 AM > Subject: Re: Ada The Best Language? ... > > Almost all printfs are compile-time printfs. > I beg to differ. All printfs must be run-time interpreters, otherwise they > couldn't support variable format strings -- i.e., the string that defines > the > way the output elements are to be formatted. > I think you're talking about different things here. A (conforming hosted) C implementation must provide a printf (and scanf etc.) that runtime interpret the format string, yes. But most, I'd bet over 99%, of *printf and *scanf calls use literal (= compiletime constant) formats. It would be legal for an implementation to "precompile" these into specific per-datum operations; I don't know of any that does, though gcc with -Wformat does compile-time _check_ for agreement between the conversion specifier (%d, %s, etc.) and argument, which is not required and not generally possible for varargs. Fortran also permits runtime-variable formats -- but again the overwhelming majority of actual formats are constant. > The other thing about prontf that is different from Ada is the fact that it > (as well as many other C functions) takes a variable number of arguments. > Many? The only varargs functions in the standard C library are the *printf and *scanf families. POSIX/Unix adds open (really only optional not variable), fcntl, syslog, and execl*. This is out of some thousand or so total, although I expect printf in particular is among the most frequently used. Occurrence in user (and third-party) code is of course up to the programmer(s), but IME is not that common; YMMV. The bad part is not that number (and types) of arguments is variable -- Ada, and C++, accomplish that safely but within limits with overloads, templates/generics and defaults -- it is that C-varargs usually aren't checked for correct type(s) and number, and in conventional compile+link systems, can't be; I can imagine something like IBM VisualAge could check, but I have no idea if it does. -- - David.Thompson 1 now at worldnet.att.net