Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/5/84; site angband.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!zehntel!hplabs!hao!seismo!ut-sally!mordor!angband!sjc
From: sjc@angband.UUCP (Steve Correll)
Newsgroups: net.lang.mod2
Subject: Re: Modula-2 I/O
Message-ID: <17@angband.UUCP>
Date: Sat, 22-Sep-84 19:52:00 EDT
Article-I.D.: angband.17
Posted: Sat Sep 22 19:52:00 1984
Date-Received: Wed, 26-Sep-84 04:53:44 EDT
Distribution: net
Organization: S-1 Project, LLNL
Lines: 40

I like Mike Powell's idea of adapting Unix "printf" for use with Modula-2.
Despite its shortcomings, I like the combination of convenience and
(even more important) readability which "printf" provides.

Perhaps the objection to variable-length argument lists could be
answered by taking a hint from the Unix "execv" system call and making
"printf" take exactly two arguments, the first of them being a format
string and the second being an open array of addresses of the desired
data items.  (The Unix "argv" argument employs a similar notion.)

As in the Unix implementation, the user would be expected to terminate
the list of addresses with a sentinel like NIL so that the callee knows
where to stop; although this is unnecessary in "printf", where the
format string dictates the number of items required, the redundancy
would allow runtime checking of the number of items. (Note that relying
on the Modula-2 "high" mechanism rather than a sentinel would force the
caller to declare an array of exactly the right size for each call.)

Admittedly, this is a bit less convenient than the C language version,
particularly when the caller must store constants into variables so
as to obtain addresses for them. But I rarely find I want to pass
constants to "printf".

As for the objection that "\n" in the C language poses portability
problems in comparison with "writeln" in Pascal, perhaps the Modula-2
"printf" should regard "\n" as meaning exactly what "writeln" does:
generate a new line in whatever manner is appropriate to the underlying
file system.

While the "\nnn" notation (where n is an octal digit) for specifying an
unprintable character is part of the C language rather than the Unix
"printf", I'd like the Modula-2 "printf" to retain it, since it seems
consistent with spirit of the Modula-2 "nnC" notation.


                                                           --Steve Correll
sjc@s1-c.ARPA, ...!decvax!decwrl!mordor!sjc, or ...!ucbvax!dual!mordor!sjc
-- 
                                                           --Steve Correll
sjc@s1-c.ARPA, ...!decvax!decwrl!mordor!sjc, or ...!ucbvax!dual!mordor!sjc