[comp.lang.c++] M2 IO

nevin1@ihlpf.ATT.COM (00704a-Liber) (04/16/88)

In article <8804140925.AA13150@klaus.olsen.uucp> Info-Modula2 Distribution List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> writes:
>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;

Yes, but when you use printf() you have to declare the type of each
variable in the format string.  If you use C++ streams the compiler does
this for you.  I know of no other way to do something like this with a
variable number of arguments.

>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?

No.  Doing this tends to lead to unreadable code.  For example:  If I
overload the word 'or' as an infix operator, this sentence no longer has
the same meaning that I intended (this is because 'word' becomes 'w or d'.
Did you find the other 'word' in that sentence which contains 'or' yet?).
It also leads to nightmares for the parser (is '/+' an error or an overload
operator, etc.).

>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.

Learn about the language before you criticize it!!!  C++ has both
call-by-reference and call-by-value (the former being new with respect to C
and the latter being the same as passing an address in C), as well as a way
to have automatic dynamic type checking (if you want the additional runtime
overhead that's required).
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah