🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #321

Re: Overloading Operators: Extension to Language

#321
From: Thomas Koenig
Date: Tue, 03 Oct 1989 21:08
29 lines
1686 bytes
Here comes another (more or less necessary) view...

I think that overloading operators may be nice but not necessary. In my
opinion, there is a much simpler solution with pretty much the same
effect.

How about an extension to the language which would allow functions to
return not only predefined types such as integers, reals and so on but
also records and arrays?  What I'm thinking of could look like this:

TYPE COMPLEX= RECORD RE,IM:REAL END;
PROCEDURE ADDC(A,B:COMPLEX):COMPLEX;
BEGIN
   B.RE:=B.RE+A.RE;
   B.IM:=B.IM+A.IM;
   RETURN B;
END ADDC;

This would result in expressions like
D:=ADDC(MULTC(B,A),DIVC(C,A));
which is, in effect, Polish notation. It would take a little bit of
getting used to to read, but it is better than nothing; it also wouldn't
need a drastic alteration of the language. In fact, the proposed
standard for ANSI-C has required this kind of thing for records (or
structures, as they are called in C).

Thomas  Koenig                   UI0T@DKAUNI2.BITNET
                                 UI0T%DKAUNI2.BITNET@CUNYVM.CUNY.EDU
                         (soon)  UI0T@IBM3090.RZ.UNI-KARLSRUHE.DE
Technical Details
Message-ID: <"89-10-03-22:05:28.25*UI0T"@DKAUNI2.BITNET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!DKAUNI2.BITNET!UI0T

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!DKAUNI2.BITNET!UI0T
From: UI0T@DKAUNI2.BITNET (Thomas Koenig)
Newsgroups: comp.lang.modula2
Subject: Re:  Overloading Operators: Extension to Language
Message-ID: <"89-10-03-22:05:28.25*UI0T"@DKAUNI2.BITNET>
Date: 3 Oct 89 21:08:31 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@PSUVM.PSU.EDU>
Organization: The Internet
Lines: 29
X-Unparsable-Date: Tue, 3 Oct 89 22:05:00 LCL