Re: why use -> (not .) with pointers?
- From: Tydr Schnubbis <fake@xxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 20:11:04 GMT
Lew Pitcher wrote:
I don't think he's talking about the fact that astruct->x is a shorthand for (*astruct).x at all. I think he's just saying that the early compilers used the syntactical difference between astruct->x and astruct.x to decide whether to generate instructions that used indirect, or conversely indirect addressing.-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
lawrence.jones@xxxxxxx wrote:Felix Kater <f.kater2@xxxxxxx> wrote:
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?
Not anymore. But back in the dark ages, C was much less concerned about types than it is today and would allow pretty much *anything* as the left operand of . or ->. In that environment, the compiler couldn't figure out what to do, so having two different operators was essential.
Nonsense.
Even K&R (1st Edition) admits that the -> notation is 'syntactic sugar' (my terms). The actual quote from "The C Programming Language" is "...pointers to structures are so frequently used that the -> notation is provided as a convenient shorthand."
.
- References:
- why use -> (not .) with pointers?
- From: Felix Kater
- Re: why use -> (not .) with pointers?
- From: lawrence . jones
- Re: why use -> (not .) with pointers?
- From: Lew Pitcher
- why use -> (not .) with pointers?
- Prev by Date: Re: Implementing my own memcpy
- Next by Date: Re: Portability
- Previous by thread: Re: why use -> (not .) with pointers?
- Next by thread: Re: why use -> (not .) with pointers?
- Index(es):
Relevant Pages
|