Re: These are identical, right? char const* and const char*
From: Leor Zolman (leor_at_bdsoft.com)
Date: 03/22/04
- Next message: BCC: "Reading in a tab delimited file?"
- Previous message: Dmitry Epstein: "Re: Template-member definition"
- In reply to: Hattuari: "Re: These are identical, right? char const* and const char*"
- Next in thread: Hattuari: "Re: These are identical, right? char const* and const char*"
- Reply: Hattuari: "Re: These are identical, right? char const* and const char*"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 22 Mar 2004 00:57:16 GMT
On Sun, 21 Mar 2004 19:47:28 -0500, Hattuari <susudata@setidava.kushan.aa>
wrote:
>Leor Zolman wrote:
>
>> On Sun, 21 Mar 2004 16:14:36 -0500, Hattuari <susudata@setidava.kushan.aa>
>> wrote:
>
>>>The answere was on page 96 of TC++PL, SE. Is there any semantic
>>>difference between the two forms?
>>
>> None. There are a slew of type specifiers that can appear adjacently in
>> any
>> order without affecting the semantics. Some orderings tend to be used
>> more than others; you won't see too many programs written with lines like:
>> int unsigned i = 20u;
>> but it is perfectly legal.
>
>This is something Java quashed early on. A bit of personal experience might
>explain my opinion on this matter. When I was young, I learned that it
>didn't matter which order I did certain mathematical calculations. I
>thought that was an interesting proposition, do I established the habit of
>not doing my calculations in any order other than following rules of
>precedence. Not until I was in my 30s did I realize this had been a
>mistake. I should have established a uniform system of working left to
>right if precedence didn't override the rule.
One thing I actually like about teaching Java is that when anyone asks why
the order of "public static void main(...)" is the way it is, I can simply
answer "because Java requires it" rather than having to come up with any
motivating justification ;-)
>
>And a specific incident comes to mind as well. I was working with a very
>brillian man who had a PhD in Computer Science from Cal. Berkely. I was
>designing a user interface and showed it to him. I explained that they
>could do it this way, or that way, or ... He asked why. My response was
>that it gave the user flexibility. Again he asked why. I couldn't answer.
>Then he said all I was accomplishing was to make my job and the user's job
>more confusing.
>
>"If it is suffixed by u or U, its type is the first of these types in which
>its value can be represented: unsigned int, unsigned long int. If it is
>suffixed by l or L, its type is the first of these types in which its value
>can be represented: long int, unsigned long int. If it is suffixed by ul,
>lu, uL, Lu, Ul, lU, UL, or LU, its type is unsigned long int."
Actually, that "u" in my example was totally superfluous to the point, and
in a program I was writing myself I probably wouldn't even have bothered
using it. But I guess it helped to make the code uglier, and I was
probably subconsciously going for the "ugly effect" to help make my point.
>And my opinion is Dr. Jim was right!
>
>> Dan Saks has been on a fairly lonely crusade
>> pushing for cvr-qualifiers such as "const" to appear to the /right/ of the
>> type they're modifying, so that the declarations can be read "naturally"
>> from right-to-left:
>>
>> char const* c1; // c1 is a pointer to const char
>>
>> (Bjarne makes that very point at the bottom of page 96).
>>
>> Occasionally one even sees Dan's style in use ;-) (Dan is a buddy of mine
>> and I kid him about this all the time, not because it isn't a good idea,
>> but because it seems to me that getting folks to change old habits like
>> that without offering a "bigger" payoff is a losing battle...)
>
>And I understand there is a bounty on my head put up by veteran Mathematica
>users because I persuaded wri to change the functionality of of the alt and
>ctrl keys so it matched the other tools on my Linux desktop, as well as the
>standard of Microsoft desktop. And I still have a hard time adjusting to
>what I asked for.
"Be careful for what you ask for... "
>
>What would Dan say about imposing specific ordering on all cv-qualifier and
>type specifiers, etc? Please note very carefully that I was not fool
>enough to actually articulate that reasonable proposal as a genuine
>proposal.
Dan is way too pragmatic to probably do much more than roll his eyes at
that one. But would you like a real opportunity to help mold a great new
language, at a time the creator is still quite open to suggestions? Check
out Walter Bright's D language at www.digitalmars.com. I just had the
pleasure of attending his talk on D at SD West, and I'm pumped. Just during
that 90+ -minute presentation, I think there were two or three language
features that audience members persuaded him to re-think and possibly
modify...
-leor
-- Leor Zolman --- BD Software --- www.bdsoft.com On-Site Training in C/C++, Java, Perl and Unix C++ users: Download BD Software's free STL Error Message Decryptor at: www.bdsoft.com/tools/stlfilt.html
- Next message: BCC: "Reading in a tab delimited file?"
- Previous message: Dmitry Epstein: "Re: Template-member definition"
- In reply to: Hattuari: "Re: These are identical, right? char const* and const char*"
- Next in thread: Hattuari: "Re: These are identical, right? char const* and const char*"
- Reply: Hattuari: "Re: These are identical, right? char const* and const char*"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|