Re: why use -> (not .) with pointers?



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.

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.

The best way to do this is to deprecate '->'

But, helas, this is not going to happen any time soon.

jacob

.



Relevant Pages

  • Re: why use -> (not .) with pointers?
    ... > Felix Kater wrote: ... >> when accessing the variables in a struct: What's the reason why in C ... > the distinction exists since the compiler can always ... and there was a pointer, ...
    (comp.lang.c)
  • Re: why use -> (not .) with pointers?
    ... > Felix Kater wrote: ... >> when accessing the variables in a struct: What's the reason why ... > distinction exists since the compiler can always figure it out. ... and there was a pointer, ...
    (comp.lang.c)
  • Re: How to convert Infix notation to postfix notation
    ... and make all strings const save where the intent ... function whose contract is to change the string. ... the compiler "just" prevents the string ... try to do using the pointer you get. ...
    (comp.lang.c)
  • Re: Mex Overflow Error Using Free Borland Compiler
    ... >>>would clean up a lot of code by eliminating the pointer dereferences. ... >>>guaranteed by the standard and should not be relied on. ... >>>You can try the GNU C compiler available on mingw or cygwin. ... >>>the Constraints are then both operands shall have arithmetic type. ...
    (comp.soft-sys.matlab)
  • Re: Anybody here endure C/Cpp? (.h to .inc conversion)
    ... Pascal or Stdcall convention... ... "PFNGLPOINTPARAMETERFEXTPROC" to be a type that's a pointer to a function ... DWORD, using a 32-bit compiler, with an address in it...adding the ... this is working on the premise that OpenGL does it like most others ...
    (alt.lang.asm)