🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4183

Re: M2 IO

#4183
From: Robert Nagler
Date: Thu, 14 Apr 1988 09:25
41 lines
2234 bytes
C++ IO interests me.  I find the syntax:
        printf( cout, "error message %s %s %d\n", string1, string2, rc );

more readable than:
        cout << "error message " << string1 << " " << string2 << " " << rc;

Particularly, when I might have the following in my code:
        rc = ( rc << 1 ) & 0xff;
        cout << "error message " << string1 << " " << string2 << " " << rc;

(How do you get at special options such as %-10s, %4.5f, %02d, etc.?)

Operator overloading is far too limited.  A truly flexible language
might allow encoding "write" as follows:
        cout write "error message " string1 " " string2 " " rc

Does C++ allow infix procedures other than the standard set?
It seems that overloading the shift operator is a bogus attempt at
"free form" expression.  Why not allow a true arbitrary infix notation?
The code would be more readable.  Furthermore, why should identifiers
be limited to alpha-numerics.  I might want to write the following:
        cout open! "myfile"
where the "!" means to overwrite the file if it exists while:
        cout open "myfile"
calls a non-destructive open.

In reality, who cares?  I haven't got time to implement an INC(M2)
compiler and/or preprocessor so I just use a simple library module that
uses the same old form (essentially) of printf.  The trick (for those
of you who are programming M2) is using Modula-2 generics:
    PROCEDURE Write(
        format : ARRAY OF CHAR;
        arg    : ARRAY OF SYSTEM.BYTE
        );

Note the advantage of M2 generics over C++ is that you not only get
the pointer, but you have the option of pass-by-value or pass-by-reference.
Another important feature is that M2 generics pass the size of the type
which can used in a limited form of dynamic type checking.

Rob Nagler
Technical Details
Message-ID: <8804140925.AA13150@klaus.olsen.uucp>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mailrus!ames!pasteur!ucbvax!unizh.UUCP!nagler%olsen

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mailrus!ames!pasteur!ucbvax!unizh.UUCP!nagler%olsen
From: nagler%olsen@unizh.UUCP (Robert Nagler)
Newsgroups: comp.lang.modula2
Subject: Re: M2 IO
Message-ID: <8804140925.AA13150@klaus.olsen.uucp>
Date: 14 Apr 88 09:25:47 GMT
Sender: usenet@ucbvax.BERKELEY.EDU
Reply-To: Info-Modula2 Distribution List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu>
Organization: The Internet
Lines: 41