'exit(1);' considered useless; p - (nf)

rpw3 at fortune.UUCP rpw3 at fortune.UUCP
Tue Feb 14 19:13:33 AEST 1984


#R:utah-gr:-107700:fortune:26900025:000:1602
fortune!rpw3    Feb 13 21:01:00 1984

[ Please note that only worthy ideas are worthy of satire... -rpw3]

Why not generalize your generalized "%p" format one better?  :-)

Make ALL the formats be routines, called through PrintfFormatTable["z"-"a"+1].

Let all the "standard" routines ("%d" = decimal, etc.) have their addresses
loaded into PrintfFormatTable (which must be in read/write memory) at load
time, but allow the programmer to load his/her own fave rave routines over that.(So if I want a "%j" to call routine "frazzle", somewhere early in "main()"
say 
		extern PrintfFormatTable[], frazzle();
		...
		PrintfFormatTable["j"-"a"] := frazzle;
		...

and from then on, voila!, 'printf("...%j...",arg)' will call "frazzle"
with the argument convention exactly as shown in the preceding article.
Since one of the flags to "frazzle" will be whether it was called as
"%j" or "%J", PrintfFormatTable need only be 26 entries (saving space).

In fact, this idea may be implemented WITHOUT changing the binaries
of "stdio", since all we have to do is create the user routine "pRintf"
(big-R'ted printf) which handles PrintfFormatTable completely invisibly
to "printf", which is called as needed to print individual argument types.
Of course, "pRintf" should default most of the standard formats to calling
"printf", unless superseded in PrintfFormatTable.

The only drawback I see is changing all the printf's in all our programs
to pRintf's, but what are editors for?

Rob Warnock

UUCP:	{sri-unix,amd70,hpda,harpo,ihnp4,allegra}!fortune!rpw3
DDD:	(415)595-8444
USPS:	Fortune Systems Corp, 101 Twin Dolphins Drive, Redwood City, CA 94065



More information about the Comp.unix mailing list