Re: Structures, Pointer and gets
Thomas Stegen wrote:[color=blue]
>
> Joe Wright wrote:
>[color=green]
> > Thomas Stegen wrote:
> >[color=darkred]
> >>Joe Wright wrote:
> >>
> >>
> >>>Yes indeed. I am of the old school that differentiates between values
> >>>and objects. I read pointer as an object which may hold a value which is
> >>>the address of another object. Others call an address value a pointer. I
> >>>understand but I disagree.
> >>
> >>You disagree with a standard definition? Interesting... :)
> >>[/color]
> >
> > Why interesting?[/color]
>
> Because the most you can say is that the definition is flawed.
> A definition is, by definition, correct.
>[color=green]
> > Does the Standard confuse value and object? Maybe.[/color]
>
> It does not. Objects can have type pointer to T. Values can have type
> pointer to T. Sheldon quoted an appropriate from the standard with which
> you disagree (You are saying that the address of an object is not a
> pointer.)
>[/color]
I agree that both objects and values can have type 'pointer to T'.
Because a value has pointer type does not make it a pointer. From K&R2
the first sentence of Chapter 5: reads "A pointer is a variable that
contains the address of a variable." I know that K&R is not the Standard
but if Kernighan and Ritchie agree on something about C, it's good
enough for me.
[color=blue][color=green]
> > Let's examine two objects..
> >
> > char arr[10];
> > char *arp;[/color]
>
> As your example demonstrates something different from what you were
> saying I snipped most of it.
>
> You are saying (at least said) that arp is a pointer, whereas &arp is
> not. Note that when arr is evaluated it is converted to a value which
> is the address of the first element in the array. This value is not
> stored in any object and so is by your disagreement with the standard
> not a pointer. You just have to look at clause 6.3.2.1#2 to see that
> this value is indeed a pointer.
>[/color]
I'll 'say' it again for the listening impaired. A value is not a pointer
even if it has pointer type. The pointer is the object that holds the
value.
It's not just about pointers. Consider..
int a; /* a is an object of type int */
a = 5; /* 5 is a literal value of type int */
Although (a == 5) is true, 5 is not an object.
I've had this discussion before. It is clear as crystal to me. That
others can't see it as I do truly baffles me.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Thomas Stegen wrote:[color=blue]
>
> Joe Wright wrote:
>[color=green]
> > Thomas Stegen wrote:
> >[color=darkred]
> >>Joe Wright wrote:
> >>
> >>
> >>>Yes indeed. I am of the old school that differentiates between values
> >>>and objects. I read pointer as an object which may hold a value which is
> >>>the address of another object. Others call an address value a pointer. I
> >>>understand but I disagree.
> >>
> >>You disagree with a standard definition? Interesting... :)
> >>[/color]
> >
> > Why interesting?[/color]
>
> Because the most you can say is that the definition is flawed.
> A definition is, by definition, correct.
>[color=green]
> > Does the Standard confuse value and object? Maybe.[/color]
>
> It does not. Objects can have type pointer to T. Values can have type
> pointer to T. Sheldon quoted an appropriate from the standard with which
> you disagree (You are saying that the address of an object is not a
> pointer.)
>[/color]
I agree that both objects and values can have type 'pointer to T'.
Because a value has pointer type does not make it a pointer. From K&R2
the first sentence of Chapter 5: reads "A pointer is a variable that
contains the address of a variable." I know that K&R is not the Standard
but if Kernighan and Ritchie agree on something about C, it's good
enough for me.
[color=blue][color=green]
> > Let's examine two objects..
> >
> > char arr[10];
> > char *arp;[/color]
>
> As your example demonstrates something different from what you were
> saying I snipped most of it.
>
> You are saying (at least said) that arp is a pointer, whereas &arp is
> not. Note that when arr is evaluated it is converted to a value which
> is the address of the first element in the array. This value is not
> stored in any object and so is by your disagreement with the standard
> not a pointer. You just have to look at clause 6.3.2.1#2 to see that
> this value is indeed a pointer.
>[/color]
I'll 'say' it again for the listening impaired. A value is not a pointer
even if it has pointer type. The pointer is the object that holds the
value.
It's not just about pointers. Consider..
int a; /* a is an object of type int */
a = 5; /* 5 is a literal value of type int */
Although (a == 5) is true, 5 is not an object.
I've had this discussion before. It is clear as crystal to me. That
others can't see it as I do truly baffles me.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Comment