Topic: Four places.
Author: "Tom s" <No.Email@Address.ucar.edu>
Date: Thu, 18 May 2006 10:57:46 CST Raw View
kanze posted:
> (Imagine for a moment the effect on existing code of removing the
> array-to-pointer conversion and giving arrays full value semantics.)
Extremely easy, and without breaking any code.
Decay an array to a pointer to its first element in FOUR places, and make
it remain as an array EVERYWHERE else.
1) When an implicit conversion is wanted:
Example A:
char array[67];
char * p = array;
Example B:
void Func( char * ); /* Declaration */
char array[67];
Func( array );
2) When the dereference operator is applied:
Example A:
char array[67];
char c = *array;
3) For arithmetic, equality, greater than/less than:
Example A:
char array[67];
char *p = array + 56;
Example B:
char array[67]; /* Global object */
bool DetermineIfAhead( const char* const p)
{
return p > array;
}
Example C:
char array[67];
char monkey[43];
bool the_same_address = array == monkey;
bool monkey_ahead = monkey > array;
4) When block brackets are applied:
Example A:
char array[67];
char c = array[6];
/* Which should be translated to:
char c = *(array + 6);
*/
Now my original code should print:
SomeFunc1: Array
SomeFunc2: Array
SomeFunc3: Array
The sooner this goes into the Standard, the sooner C++ improves.
-Tom s
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: kuyper@wizard.net
Date: Thu, 18 May 2006 14:18:45 CST Raw View
Tom s wrote:
> kanze posted:
>
> > (Imagine for a moment the effect on existing code of removing the
> > array-to-pointer conversion and giving arrays full value semantics.)
>
>
> Extremely easy, and without breaking any code.
>
>
> Decay an array to a pointer to its first element in FOUR places, and make
> it remain as an array EVERYWHERE else.
>
>
> 1) When an implicit conversion is wanted:
That covers every one of the cases you gave us, which involve the
implicit conversions that occur as the result of a function call, so
such a change wouldn't affect the problem you're complaining about.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]