> 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.

  wow.. you never know what you find these days.. maybe i never saw
  these bugs because i always use the (* ..) :>
 
> >   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."

  of course i tell them what it means.. but when you start.. a common
  base is required.. once that common base is established.. then you
  can go into the "extra" bits and pieces..

  the same argument applies when you teach students:

    i++ and ++i

  i teach them i=i+1 first.. then once they understand it.. i can go
  into the particulars of the different syntax - in this case, use and
  then increment and increment first, then use.

> 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!

    (* (* (* struct).substruct).subsubstruct).attribute

  hmm.. ok.. bit messy.. :>> it would be much easier written as

    struct->substruct->subsubstruct->attribute

  but it is always good to see BOTH styles :>

> >   simple case.. :> works perfectly.. of course i tell them that
> >   "->" can be used too..
> 
> "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.

  ok.. this is what i teach them:

---
7.1 Pointer Variable Declarations

Pointers are variables that contain a memory address. The address
address stored in a pointer variable references a portion of memory 
that is used to store another data type.
---

  i guess that says the same thing :> just different words :))
   
> >   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! :)

  what i meant to say was '3Com' wrote the C header files.. if you
  are going to distribute source code.. to make understanding better
  from the developer base.. consistancy in style should be applied.

  cheers.

az. 
--
Aaron Ardiri 
Lecturer                       http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN       
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 656 1143           A/H: +46 26 10 16 11

Reply via email to