Path: 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 ListOrganization: The Internet Lines: 29 X-Unparsable-Date: Tue, 3 Oct 89 22:05:00 LCL 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