Article View: comp.std.c++
Article #708Re: Exponentiation operator proposal
From: Matt Austern
Date: Wed, 14 Oct 1992 22:47
Date: Wed, 14 Oct 1992 22:47
36 lines
2444 bytes
2444 bytes
In article <ldpoc1INNbe7@exodus.Eng.Sun.COM> corbett@lupa.Eng.Sun.COM (Robert Corbett) writes: > >I just ran a quick measurement on a convenient sample of 85,000 lines of > >C and C++ code. Based on this sample "**" appears on average about once > >per every 200 lines of code. This is a pretty high occurance. ... > I find it hard to believe that there are that many instances of > multiplication following indirect referencing. How many of those > instances of ** are of the form > > /* > ** Commentary > */ > ? I can't speak for Jim (I haven't seen the code that he used for his sample), but my guess is that most of the **'s he found weren't comments, but, rather, double pointer dereference. (For example, how many times has the sequence **argv occurred in your programs?) This wouldn't cause any direct ambiguity with ** as an exponentiation operator, since exponentiation is an infix operator. However, note that it would still be necessary to define unary ** as a new operator meaning double pointer dereference. The parser would interpret ** as a single token, whether it appears in a unary or a binary context. There are a few expressions that would have their meaning changed if we made ** into an operator---probably rare ones, but I'm sure that they do crop up occasionally in real code. (a/b**c, for example) I think we probably would be better off using a different token for exponentiation. -- 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.92Oct14224724@physics2.berkeley.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!agate!mattReferences:
<1992Sep13.193507.27813@ima.isc.com> <BuJJxs.8Hx@world.std.com> <23663@alice.att.com> <1992Oct14.225725.16486@microsoft.com> <ldpoc1INNbe7@exodus.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!agate!matt From: matt@physics2.berkeley.edu (Matt Austern) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Re: Exponentiation operator proposal Date: 14 Oct 92 22:47:24 Organization: Lawrence Berkeley Laboratory (Theoretical Physics Group) Lines: 36 Message-ID: <MATT.92Oct14224724@physics2.berkeley.edu> References: <1992Sep13.193507.27813@ima.isc.com> <BuJJxs.8Hx@world.std.com> <23663@alice.att.com> <1992Oct14.225725.16486@microsoft.com> <ldpoc1INNbe7@exodus.Eng.Sun.COM> Reply-To: matt@physics.berkeley.edu NNTP-Posting-Host: physics2.berkeley.edu In-reply-to: corbett@lupa.Eng.Sun.COM's message of 15 Oct 1992 03:12:01 GMT