Re: why use -> (not .) with pointers?
- From: Lawrence Kirby <lknews@xxxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 16:11:30 +0100
On Thu, 30 Jun 2005 15:21:16 +0200, jacob navia wrote:
> Felix Kater wrote:
>> Hi,
>>
>> when accessing the variables in a struct: What's the reason why in C
>> you have -> and . instead of only . ? Are there cases in which the
>> compiler couldn't figure out what to do?
>>
>> Felix
> I think the answer is NO, there aren't any reasons why
> the distinction exists since the compiler can always
> figure it out.
True.
> If we would always use '.' and there was a pointer, the
> compiler could test if we have instead of a structure,
> a pointer to a structure, then generate a dereferencing of
> the pointer without much trouble.
True.
> The best way to do this is to deprecate '->'
>
> But, helas, this is not going to happen any time soon.
That assumes that this is a sensible and desirable thing to do. It would
make the language syntax marginally simpler, whereas the existing ->
operator highlights the fact that you are using a pointer, which IMO is no
bad thing in C.
Lawrence
.
- References:
- why use -> (not .) with pointers?
- From: Felix Kater
- Re: why use -> (not .) with pointers?
- From: jacob navia
- why use -> (not .) with pointers?
- Prev by Date: Re: #defines and strings
- Next by Date: Re: casting to unsigned char for is*() and to*() functions
- Previous by thread: Re: why use -> (not .) with pointers?
- Next by thread: Re: why use -> (not .) with pointers?
- Index(es):
Relevant Pages
|