🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #710

Re: Exponentiation operator proposal

#710
From: Matt Austern
Date: Fri, 16 Oct 1992 17:19
35 lines
2576 bytes
In article <Bw8ADK.144@news.orst.edu> myersn@hobo.ECE.ORST.EDU (Nathan Myers) writes:

> I have long ignored "exponentiation proposal" notes, but it seems
> time to point out that there is no operator~(T,T) defined yet.
> Simply allowing it to be defined would permit experimentation,
> without committing anybody to a bigger language if the use didn't
> "catch on".

Binary operator~ is certainly one possibility for exponentiation.
operator*^ and operator^^ are other possibilities; of the three, I
think that *^ is the best.

Regardless of the name, however, I feel strongly that a real
exponentiation operator is far better than an operator which can be
defined as exponentiation by the user.  First, a compiler is much more
likely to optimize exponentiation aggressively if it is built into the
language than if it's something the user tacks on.  (Depending on
exactly what is inline and in scope, it might not even be possible to
do certain optimizations with a user-defined operator.)  

Second, if users each define this operator for themselves, then each
programmer will almost certainly define it slightly differently.  This
is likely to cause subtle bugs and conflicts when the work of
different programmers is put together.

Finally, and most important: things like exponentiation simply belong
either in the language or in the library; users should not be forced
to write them for themselves, any more than users should be forced to
implement malloc() or sin() or qsort().  Defining commonly used
operations and functions is what languages and libraries are for.
--
Matthew Austern                   Just keep yelling until you attract a
(510) 644-2618                    crowd, then a constituency, a movement, a
austern@lbl.bitnet                faction, an army!  If you don't have any
matt@physics.berkeley.edu         solutions, become a part of the problem!
Technical Details
Message-ID: <MATT.92Oct16131945@physics.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!know!cass.ma02.bull.com!think.com!ames!agate!agate!matt
References: <BuJJxs.8Hx@world.std.com> <23663@alice.att.com> <1992Oct14.225725.16486@microsoft.com> <Bw8ADK.144@news.orst.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!know!cass.ma02.bull.com!think.com!ames!agate!agate!matt
From: matt@physics.berkeley.edu (Matt Austern)
Newsgroups: comp.std.c++,comp.lang.c++
Subject: Re: Exponentiation operator proposal
Message-ID: <MATT.92Oct16131945@physics.berkeley.edu>
Date: 16 Oct 92 17:19:45 GMT
References: <BuJJxs.8Hx@world.std.com> <23663@alice.att.com>
 <1992Oct14.225725.16486@microsoft.com> <Bw8ADK.144@news.orst.edu>
Reply-To: matt@physics.berkeley.edu
Organization: Lawrence Berkeley Laboratory (Theoretical Physics Group)
Lines: 35
NNTP-Posting-Host: physics.berkeley.edu
In-reply-to: myersn@hobo.ECE.ORST.EDU's message of 16 Oct 92 19:05:38 GMT