home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.std.c++:1186 comp.lang.c++:13678
- Newsgroups: comp.std.c++,comp.lang.c++
- Path: sparky!uunet!utcsri!torn!cunews!nrcnet0!bnrgate!bcrka451!bcrki65!sjm
- From: sjm@bcrki65.bnr.ca (Stuart MacMartin)
- Subject: Re: Exponentiation operator proposal
- Message-ID: <1992Sep15.141940.12960@bcrka451.bnr.ca>
- Sender: 5E00 Corkstown News Server
- Organization: Bell-Northern Research Ltd., Ottawa, Canada
- References: <1992Sep13.193507.27813@ima.isc.com> <BuJJxs.8Hx@world.std.com> <23663@alice.att.com>
- Date: Tue, 15 Sep 1992 14:19:40 GMT
- Lines: 36
-
- In article <23663@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes:
- >How frequent is a**p anyway? (has anyone got any data?)
-
- I always avoid ** when I mean a mixture of multiplication and dereference
- (in C). I use parentheses to make it clear what is dereference and what
- is multiplication. Thus I would always write: a * (*p)
-
- Or, in the case of a***p, I would write: a * (**p)
-
- There are two situations where I might have generated a**p accidentally:
-
- 1. #define THE_VALUE *p /* This is C code. Should be (*p) anyway */
-
- a*THE_VALUE
-
- 2. a*i
- global change of i to *p
-
-
- Case 1 should not show up in C++ code and is poor style in C code
- because of the missing parentheses in the #define.
-
- Case 2 should be a global change to (*p) anyway because of the
- danger of a/i being changed to a/*p (comment!)
-
- So no, I do not intentionally generate code of the problem form.
- I have seen such code, but only in code that I consider a nightmare
- to read and maintain anyway. Keep in mind also that I know of the
- "global change results in comment" problem, so that means there must
- be some a**p code around here generated that way.
-
- Stuart
- --
- : Stuart MacMartin email: sjm@bnr.ca :
- : Bell-Northern Research phone: (613) 763-5625 :
- : PO Box 3511, Stn C, Ottawa, K1Y-4H7, CANADA Standard disclaimers apply. :
-