Re: Is pointer syntax logical?
Re: Is pointer syntax logical?
- Subject: Re: Is pointer syntax logical?
- From: Daniel DeCovnick <email@hidden>
- Date: Thu, 26 Jul 2007 15:36:42 -0700
It was an explanation of why we don't simply have a pointer
declaration syntax "pointer a;" except for void *, which can't be
dereferenced without a cast.
-Dan
On Jul 26, 2007, at 3:21 PM, Kevin Kuehl wrote:
--- Daniel DeCovnick <email@hidden> wrote:
Having one declare a type, both automatic and
heap-allocated, and not
allowing dereferencing of a void *, is as close as C
comes to strong
typing. And it does not come any closer:
float f = 5.123;
float *fp = &f;
int *ip = (int *)fp;
is perfectly valid code. But you'll find that *ip is
not 5. Rather,
it's 1084485534. This may well be machine-dependent.
I fail to understand the point of this example. No
one who knows C would expect the value "*ip" to be 5.
"ip" points to a memory location containing the
floating point representation of 5.123 and that isn't
00000000 00000000 00000000 00000101.
Kevin Kuehl
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden