🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3739

Generic procedures

#3739
From: David Hiebeler
Date: Mon, 17 Aug 1987 17:17
30 lines
2056 bytes
References:

Keywords:


After using Pascal, one of the features I especially enjoy about Modula-2
is the ability to write more generic procedures.  For example, a proc which
recieves an ARRAY OF CHAR, of whatever length.  Or, if you want to get a 
little deeper, one which recieves an ARRAY OF WORD so that the proc may
use REALS, INTEGERS, CARDINALS, or whatever.
  My Stack module imports the DataType to be stored in the stack from a
module called TypeOfData which simply exports a transparent type.  Then,
the module which is calling the Stack module may also import DataType and
declare vars of that type, etc. (If DataType is opaque, you can't do things
like send vars of that type to WriteInt, even if DataType is declared as
INTEGER).
  These things are much better than Pascal as far as data abstraction goes.
However, give me an inch and I want a kilometer.  Now I find that I want to
write a WriteInt procedure, for example, that recieves a File parm stating
where the output will go, an INTEGER to output, and OPTIONALLY a fieldwidth
specifier.  No such luck.  I don't know of any ways, no matter how tricky,
to write a procedure that can recieve a variable number of parameters.
Any ideas?  Right now, I have 2 procs: WriteInt, and WriteIntf (formatted),
and similarly for other data types (REALS, etc.).

                             -D.H.
----
David Hiebeler       hiebeler@csv.rpi.edu
Chatham, NY         "Illusions, Richard!  Every
(also Troy, NY)      bit of it illusions!"
Technical Details
Message-ID: <22@rpicsb8>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!rutgers!nysernic!rpicsb8!csv.rpi.edu!hiebeler

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!rutgers!nysernic!rpicsb8!csv.rpi.edu!hiebeler
From: hiebeler@csv.rpi.edu (David Hiebeler)
Newsgroups: comp.lang.modula2
Subject: Generic procedures
Message-ID: <22@rpicsb8>
Date: Mon, 17-Aug-87 13:17:34 EDT
Article-I.D.: rpicsb8.22
Posted: Mon Aug 17 13:17:34 1987
Date-Received: Tue, 18-Aug-87 04:50:16 EDT
Sender: nobody@rpicsb8
Reply-To: hiebeler@csv.rpi.edu (David Hiebeler)
Organization: RPI CS Dept, Troy, New York
Lines: 25