G
glen herrmannsfeldt
BartC said:also think sometimes (like here) if java-likethe question is how syntax to choose to distinguish between
pointers-to-one and pointers-to-many in such cases:
void print(char* text) //pointer to undefined many
{
}
void print(char(1)* text) //pointer to one ?
{
}
syntax wouldnt be clearer
char a; //a is adress to one
char[] a; //a is adress to undefined many
char[16] a; //a is adress to chunk of 16 chars
If you want to call them addreses, you need to be careful as
to what is constant and what isn't.
In the first case, &a is a constant. In the third case,
I am not so sure, but a would be for char a[16];
In my opinion, C type syntax is broken. And that's not just the convoluted
syntax.
It's because char[] means different things in different contexts: an array
in some places, and a pointer in another:
char a[]={65,66,67}; // array
void fn (char[] a); // pointer
Not quite as many meanings as the word "static", though.
char[] meaning array would be illegal in a parameter context, but instead of
leaving that hole in the 'map' of possible types, everything moves up one
instead! The penchant for C to gloss over any dereferences needed - or not
needed - to index an array/pointer, just confuses things further.
I believe that some think that the function argument [] was a mistake,
though I sort of like it. (Not that I usually use it.)
The array case could have been done something like char a[*]={65,66,67};
indicating that there is an unknown length.
I think you have your work cut out...
-- glen