Forget the religious wars.  However, I'm up for a friendly discussion.  There
are many pages and talks on coding styles.  It amazing how pissy some people
can get over where to put your curly brackets for loops and if texts.  Here
is my opinion on what has been said so far...

>   in addition.. i hate the "->" syntax.
>
>      event->eType    to me is better written as:
>      (*event).eType

I have found a few compiler bugs where I needed to do the latter to get the
right object code.

>
>   i teach C at the university.. and you would not believe the
>   confusion of using ->, they understand (*event), as it works
>   the same for primitive types and structures..
>
>     &var   -> the address of
>     *var   -> whats at the address of
>

Personally I have never had any problem with the arrow syntax.  It is very
intuitive to me.  I just think to myself, "I am now pointing to this variable
that the pointer knows the base address of to get the value."

I know pointers can get hairy but learning the syntax is needed.  One good
test question is to give a student is a four level deep structure / union /
class combo and tell them to write a line that gets a variable four levels
deep just by having a reference to the base of an instance of the structure.
Yes, I do code like that and it is very handy in real time stuff!

>
>   simple case.. :> works perfectly.. of course i tell them that
>   "->" can be used too..

Since you teach it, PLEASE use this definition of the pointer that I have
used when tutoring C at a few clients.

"A pointer is a variable in which the contents of that variable is the
address of another variable.  Hence, it 'points' to something."

I have never see the word "pointer" cleared down to its original reference in
any the programming courses I have taken or texts read.  This cleared things
up for a lot of people that was confused on the subject when I was teaching
them.

>
>
>   religious war? hehe.. well.. you DONT have to use the typedefs :>
>   but... you should try and keep your code looking "similar" in
>   style to the base system - which is 3Com's code.

That I don't agree with.  We'd be doing COBOL on a Palm if we kept with
that.  Hmmm .... I'm sure someone will try to do it.  Not I! :)

Steve


Reply via email to