🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #341

Re: Defining Operators

#341
From: Win Treese
Date: Fri, 06 Oct 1989 04:03
23 lines
1320 bytes
In article <INFO-M2%89093000360807@UCF1VM> Modula2 List <INFO-M2%UCF1VM.BITNET@PSUVM.PSU.EDU> 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.
Technical Details
Message-ID: <852@crltrx.crl.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!xanth!mcnc!decvax!crltrx!treese
References: <INFO-M2%89093000360807@UCF1VM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <INFO-M2%89093000360807@UCF1VM>
Reply-To: treese@crltrx.crl.dec.com.UUCP (Win Treese)
Organization: DEC Cambridge Research Lab
Lines: 23