S
Serve Laurijssen
What are the disadvantages if C would allow referencing pointer to struct
with the dot operator?
Such as
struct X *x = ...;
x.y = 10;
Im not crying to get this added to the standard as Im happy using the arrow
operator anyway. I'm just interested in the disadvantages. Good things about
this style:
* it makes it easier for new programmers to learn the language as pointers
tend to confuse in the beginning. They wont be scared off easily and they
can learn the language at a lower pace
* Universal notation for struct members
* wont break existing code when added to a compiler
The only disadvantage I can see is that now its not immediately clear
anymore when you see x.y that x is a pointer but this is a minor
disadvantage IMO. You almost never need to know if its a pointer or not,
only in the case of bugs when x is a NULL pointer but then you're analyzing
the code thoroughly anyway, plus the tools of today can show you very well
if its a pointer or not.
Any bigger disadvantages?
with the dot operator?
Such as
struct X *x = ...;
x.y = 10;
Im not crying to get this added to the standard as Im happy using the arrow
operator anyway. I'm just interested in the disadvantages. Good things about
this style:
* it makes it easier for new programmers to learn the language as pointers
tend to confuse in the beginning. They wont be scared off easily and they
can learn the language at a lower pace
* Universal notation for struct members
* wont break existing code when added to a compiler
The only disadvantage I can see is that now its not immediately clear
anymore when you see x.y that x is a pointer but this is a minor
disadvantage IMO. You almost never need to know if its a pointer or not,
only in the case of bugs when x is a NULL pointer but then you're analyzing
the code thoroughly anyway, plus the tools of today can show you very well
if its a pointer or not.
Any bigger disadvantages?