Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!usc!venera.isi.edu!lmiller From: lmiller@venera.isi.edu (Larry Miller) Newsgroups: comp.lang.c Subject: Re: parsing the format string at compile time... Keywords: format printf parsing modula-2 Message-ID: <10082@venera.isi.edu> Date: 11 Oct 89 16:54:06 GMT References: <705@nixbur.UUCP> Reply-To: lmiller@venera.isi.edu.UUCP (Larry Miller) Distribution: usa Organization: Information Sciences Institute, Univ. of So. California Lines: 26 In article <705@nixbur.UUCP> jobrien@nixbur.UUCP (John O'Brien) writes: >I'm looked a description of Modula-2 yesterday, and one of the things >that struck me was its lack of a general purpose I/O function. Instead, >you have a collection of procedures which output one value of each type. >Thus, where you would say in C: > >printf("This is an integer: %d\n", 6); > >you would need three procedure calls in Mod-2: > >writechar("This is an integer: "); >writeint(6); >writeln; > Parsing the format string is so incredibly trivial that there can be no advantage of having to make separate function calls for each data type like this. Many implementations just code it in assembly language, giving even faster execution, but even coded in C directly, it's no more than a loop to look at each character in the format string, then switching on %. Larry Miller lmiller@venera.isi.edu (no uucp) USC/ISI 213-822-1511 4676 Admiralty Way Marina del Rey, CA. 90292