Article View: comp.std.c++
Article #163Re: Exponentiation operator proposal
From: Bjarne Stroustrup
Date: Mon, 14 Sep 1992 14:27
Date: Mon, 14 Sep 1992 14:27
47 lines
2704 bytes
2704 bytes
karl@ima.isc.com (Karl Heuer) writes > >(2) I think we could actually get ** as the exponentiation operator. > >[By defining `**' to have semantics of TIMES FETCH when the right operand > >is a pointer] > I considered this when I wrote my exponentiation essay. I decided that it > might be possible, but it's way too confusing! This would be a kludge of the > highest order. It's much better to use syntax that's not already taken -- > I've adopted "*^", as suggested by someone else some years ago. (A hybrid of > "**" and "^", sort of.) Of course it is a hack. It is a compatibility hack of the first order, but I see few TECHNICAL problems with it. and rr@world.std.com (Robert I Ransbottom) writes > I agree ** is confusing, given the potential frequency of both "dat**ptr" and > "dat**dat" it seems like a waste to deciphering such. The proponents > of **expon want a convenience. > > I think that ^^ would be more satisfying to both pointer-ers and math-ers. > > 1. Its not already taken! > . . . . . > n. Its easier to type than Karl's *^. The reason I mentioned ** is that I think that every alternative mentioned so far has something wrong with it. I see ^ as xor and ^^ bothers me. As it happens *^ doesn't bother me but my feeling was that 99% of the deamand for an exponentiation operator comes from current or past Fortran users and - in my experience - they always ask for ** and are unsatisfied with the explanations of why they can't have that syntax. How frequent is a**p anyway? (has anyone got any data?) How confusing would it really be? Many people use spaces to clarify (to their eyes, if not to everyone else's) code, e.g. a * *p. Also, not all overloading creates confusion, especially when identifier names are chosen with a minimum of care (want would x**e mean? a**xptr mean?). I doubt the case is clear cut. I am not arguing that ** is THE right solution, but that given the demand for it and the lack of ginuinely nice alternatives ** should not be written off without a thought and/or in the belief that it is technically infeasible to provide it.
Technical Details
Message-ID:
<23663@alice.att.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!allegra!alice!bsReferences:
<23660@alice.att.com> <1992Sep13.193507.27813@ima.isc.com> <BuJJxs.8Hx@world.std.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!allegra!alice!bs From: bs@alice.att.com (Bjarne Stroustrup) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Re: Exponentiation operator proposal Message-ID: <23663@alice.att.com> Date: 14 Sep 92 14:27:49 GMT Article-I.D.: alice.23663 References: <23660@alice.att.com> <1992Sep13.193507.27813@ima.isc.com> <BuJJxs.8Hx@world.std.com> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 47