Pointer asterisk placement

Started by
12 comments, last by MadKiwi 20 years, 1 month ago
pinacolada : right, which is why associativeness in this case is one of the points of criticism when talking about c/c++.

this gets especially confusing when prototyping with arrays. when prototyping a function you don''t have to supply names so this : void foo(char) would be a legal prototype and void foo(char s[]) would be, too. but what about void foo(char[]) ??? (it is legal...)
Advertisement
quote:Original post by pinacolada
That makes sense, but then the counter-argument to that is arrays. Definitely you would consider "array-ness" to be part of the type of the variable, but the array notation goes after the variable name:

int array[5]

so you can''t always group all the "type" information in one place.
I think they do int[5] array; in Java or C#? I don''t know where, but I have seen it, and sometimes I unconciously typed it like that too and the compiler would usually go wild and spam the output window with at least 10 error messages.

p.s: I wanted to answer your question regarding the array-ness, but after the second thought that it might turn this innocent thread to a neverending debate, I decided not to.
quote:Original post by alnite
quote:Original post by pinacolada
That makes sense, but then the counter-argument to that is arrays. Definitely you would consider "array-ness" to be part of the type of the variable, but the array notation goes after the variable name:

int array[5]

so you can''t always group all the "type" information in one place.
I think they do int[5] array; in Java or C#? I don''t know where, but I have seen it, and sometimes I unconciously typed it like that too and the compiler would usually go wild and spam the output window with at least 10 error messages.

p.s: I wanted to answer your question regarding the array-ness, but after the second thought that it might turn this innocent thread to a neverending debate, I decided not to.


I do believe that array-ness ought to be part of the type, it is like that in Java, and I think it ought to work the same way in all C derivatives.

C does not always agree with my preferences. I choose to tolerate that.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
yeah, i recently got back to code some stuff in c++, and this is really annoying..

in D, it was so nice.
int[SIZE] intArray;int[] dynamicIntArray;char[] charArray; // a stringint[char[]] map; // map<char[],int> a.k.a. std::map<std::string,int>  

etc..

and of course int* x; if you needed a ptr..

well well, you can't have everything.

int* x; makes much more sence for anyone who thinks in types, than int *x; does. in C days, int *X did made more sence, it was a design decision. the, for a lot of people, wrong one.



If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

davepermen.net

[edited by - davepermen on March 22, 2004 7:43:56 PM]
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

This topic is closed to new replies.

Advertisement