🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.mod2
Article #315

Re: IO (Re: Overloading)

#315
From: Geoffrey Wyant
Date: Mon, 10 Mar 1986 15:13
65 lines
3305 bytes
    > I can't TAKE it any more!!  It seems clear to me that the way it SHOULD have
    > been done is for Modula-2 to have a generalized mechanism for letting 
    > users write 
    > 1) VARARGS (variable number of parameters) and 
    > 2) variable type of parameter 
    > routines.  Then if one gets excited about not having "writeln", one can
    > write a writeln library.  And if one later gets windows, one can add an
    > optional extra parameter to indicate a window number.  Etc.  The things
    > that C, for example, didn't do right in this case were
    
    ---------------------------------------------------------------------------------

    Now, I can't take it any more !   I'm against modifying the language in general,
    and especially for adding features that reduce type-checkability.   I think a 
    "90 %" solution can be had with out modifying the language.   


     DEFINITION MODULE FormattedWordIo ;

         EXPORT QUALIFIED Write2, Write6, Write10 ;

         PROCEDURE Write2(formatString: ARRAY OF CHAR; 
                          w1, w2: WORD) ;
         PROCEDURE Write6(formatString: ARRAY OF CHAR; 
                         w1, w2, w3, w4, w5, w6: WORD) ;
         PROCEDURE Write10(formatString: ARRAY OF CHAR; 
                           w1, w2, w3, w4,..., w10: WORD) ;
    END ;

    DEFINITION MODULE FormattedIObyAddr ;
    EXPORT QUALIFIED Write2, Write6, Write10 ;

    PROCEDURE Write2(formatString: ARRAY OF CHAR; 
                     a1, a2: ADDR) ;
    PROCEDURE Write6(formatString: ARRAY OF CHAR; 
                     a1, a2, a3, a4, a5, a6: ADDR) ;
    PROCEDURE Write10(formatString: ARRAY OF CHAR; 
                      a1, a2, a3, a4,..., a10: ADDR) ;
    END ;


   MODULE Foo ;
   ....

   FormattedWordIo.Write2("This is a word io example of %d lines and %d words", 
                          1, 12) ;

   FormattedIoByAddr.Write6("Another crummy %a example of %d lines",
                            adr(some_string), length(some_string), 1,
                            NIL, NIL, NIL) ;
   END foo;


   I think you get the picture.  Its not the most elegant solution in the world.
   But it does the job.  How many times have you really needed an IO interface
   capable of handling an infinite number of parameters of heterogeneous types.
   If you really need that, cook up an IO interface that took a list, in which
   each entry had a type code, and either a word value or a pointer. Not every
   application needs variable length parameter lists, and you make everyone
   pay for it when you embed it in the language.


                                  Geoff Wyant
-------
Technical Details
Message-ID: <8603110453.AA12640@uw-beaver.arpa>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!apollo.UUCP!wyant

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!apollo.UUCP!wyant
From: wyant@APOLLO.UUCP (Geoffrey Wyant)
Newsgroups: net.lang.mod2
Subject: Re: IO (Re: Overloading)
Message-ID: <8603110453.AA12640@uw-beaver.arpa>
Date: Mon, 10-Mar-86 10:13:58 EST
Article-I.D.: uw-beave.8603110453.AA12640
Posted: Mon Mar 10 10:13:58 1986
Date-Received: Wed, 12-Mar-86 04:48:58 EST
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The ARPA Internet
Lines: 65