Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!xanth!mcnc!decvax!crltrx!treese From: treese@crltrx.crl.dec.com (Win Treese) Newsgroups: comp.lang.modula2 Subject: Re: Defining Operators Message-ID: <852@crltrx.crl.dec.com> Date: 6 Oct 89 04:03:17 GMT References: Reply-To: treese@crltrx.crl.dec.com.UUCP (Win Treese) Organization: DEC Cambridge Research Lab Lines: 23 In article Modula2 List writes: > > I was struck with an urge to think just the other day and came up with the > following observation. I was flipping through some Ada books in the library > ('cause they outnumber Modula-2 books about 20 to 1) and Ada seems to have a > feature where you can define an operator for non-standard types. For example > suppose you want to add two complex numbers. You have to: It's worth noting that CLU does this (and has been around for a long time). The compiler can do it automatically: a + b is simply syntactic sugar for typeof(a)$add(a, b) The types of a and b must match, of course. 3 + 5 is just int$add(3, 5). Win Treese Cambridge Research Lab treese@crl.dec.com Digital Equipment Corp.