Article View: comp.lang.modula2
Article #2959Re: Strings, storage management, overloading
From: Graham Perkins
Date: Fri, 27 Oct 1995 10:40
Date: Fri, 27 Oct 1995 10:40
40 lines
2306 bytes
2306 bytes
Dan.Pop@mail.cern.ch (Dan Pop) wrote:
>>"Yes, but the conversion does exist at the language definition level.
>>The language specifies that in these cases conversions have to be
>>performed and describes exactly how.
>>says Dan ...
>>what language?
>
>Any language supporting binary arithmetic operators between operands of
>different types that I know of.
>
Aha, so this is what people want to use overloading for. Now suppose
we invented a syntax that allowed programmer to describe such conversions
much the way lang. definition does:
procedure sum( m : matrix ) : real
begin .. end
procedure sum( v : vector becomes vecToMat(v) )
infix function '+' ( x,y:complex ) : complex
begin .. end
infix function '+' ( x:comlex; y:real becomes comp(y,0) ) : complex
This gets rid of need for full-blown operator overloading, and clarifies
that it really is the same task being performed, with a safe type
conversion that actually appears in the interface definition.
Now I think if you also have manifest arrays (or even lists) to cope
with the arb. length parameter problem, then 99% cases of desire
for overloading will disappear. Whoops I forgot. Lots
of people want to overload function names 'cos they can't be bothered
to invent clear description of task.
Of course C++ programmers want to overload function names because
the language designer decided that all creation and destruction
functions in a class should have the same name. What a stroke of
genius.
Technical Details
Message-ID:
<46qcv9$fjv@macondo.dmu.ac.uk>Path:
arc1-ca.pugleaf.net!yama.mcc.ac.uk!dmu!usenetReferences:
<xanthian-1310951548500001@kdolan-mac.qualcomm.com> <dewar.813674622@schonberg> <45olrg$36u@treflan.shout.net> <DGGJKD.B8y@cwi.nl> <dewar.813734622@schonberg> <danpop.813789574@rscernix> <dewar.813802488@schonberg> <danpop.813845302@rscernix>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!yama.mcc.ac.uk!dmu!usenet From: Graham Perkins <gperkins@dmu.ac.uk> Newsgroups: comp.lang.modula2 Subject: Re: Strings, storage management, overloading Date: 27 Oct 1995 10:40:41 GMT Organization: De Montfort University, Central Newsserver Leicester UK Distribution: world Message-ID: <46qcv9$fjv@macondo.dmu.ac.uk> References: <xanthian-1310951548500001@kdolan-mac.qualcomm.com> <dewar.813674622@schonberg> <45olrg$36u@treflan.shout.net> <DGGJKD.B8y@cwi.nl> <dewar.813734622@schonberg> <danpop.813789574@rscernix> <dewar.813802488@schonberg> <danpop.813845302@rscernix> NNTP-Posting-Host: mkcsst22.mk.dmu.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 1.22 (Windows; I; 16bit)