Re: [OT] A bit confused on pointers...
Re: [OT] A bit confused on pointers...
- Subject: Re: [OT] A bit confused on pointers...
- From: glenn andreas <email@hidden>
- Date: Fri, 30 Dec 2005 11:38:48 -0600
On Dec 30, 2005, at 11:16 AM, Steve Checkoway wrote:
But there's never any ambiguity about whether the operator is unary
or binary in an expression.
Never? The * operator is inherently ambiguous. Consider:
a * b;
Is b a pointer to a or is the expression a multiplied by b?
Without any
context it is impossible to know for sure. Either interpretation
constitutes
a legal expression in C.
Not true. That expression always means a multiplied by b in c. (In c
++ there might be some ambiguity as to which operator*() to use
from things like template specializations and the like.) That can
never be interpreted as dereferencing b.
Not if "a" is a type name (which makes "b" a pointer to an "a")
Thus the need for context (is "a" a variable or a type) to
disambiguate it.
e.g:
typedef unsigned long a;
unsigned long b;
a * b;
vs:
unsigned long a;
unsigned long b;
a * b;
Both are legal and completely different interpretations of what "a *
b" means.
Glenn Andreas email@hidden
<
http://www.gandreas.com/> wicked fun!
quadrium | build, mutate, evolve | images, textures, backgrounds, art
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden