type* name vs. type *name

Discussion in 'C Programming' started by Sergei Gnezdov, Mar 29, 2005.

  1. I'd think that

    type* pointerName

    is more descriptive, than

    type *pointerName

    After all, we define a type pointer, not the pointer by itself.
     
    Sergei Gnezdov, Mar 29, 2005
    #1
    1. Advertising

  2. Sergei Gnezdov wrote:
    > I'd think that
    >
    > type* pointerName
    >
    > is more descriptive, than
    >
    > type *pointerName
    >
    > After all, we define a type pointer, not the pointer by itself.


    You might want to take a look at:
    http://www.research.att.com/~bs/bs_faq2.html#whitespace

    Which certainly aggrees that type* name is preferable to type *name -
    but it ultimatly comes down to preference as both are valid.

    --
    Peter MacMillan
    e-mail/msn:
    icq: 1-874-927

    GCS/IT/L d-(-)>-pu s():(-) a- C+++(++++)>$ UL>$ P++ L+ E-(-) W++(+++)>$
    N o w++>$ O !M- V PS PE Y+ t++ 5 X R* tv- b++(+) DI D+(++)>$ G e++ h r--
    y(--)
     
    Peter MacMillan, Mar 29, 2005
    #2
    1. Advertising

  3. In article <>,
    Peter MacMillan <> wrote:
    ....
    >You might want to take a look at:
    >http://www.research.att.com/~bs/bs_faq2.html#whitespace
    >
    >Which certainly aggrees that type* name is preferable to type *name -
    >but it ultimatly comes down to preference as both are valid.


    The problem with: type* name;
    is that you might be confused by: type* name1,name2;
     
    Kenny McCormack, Mar 29, 2005
    #3
  4. Sergei Gnezdov

    Jack Klein Guest

    On 29 Mar 2005 04:00:17 GMT, Sergei Gnezdov <>
    wrote in comp.lang.c:

    > I'd think that
    >
    > type* pointerName
    >
    > is more descriptive, than
    >
    > type *pointerName
    >
    > After all, we define a type pointer, not the pointer by itself.


    Why should we care what you think? What qualifications do you have
    that we should give weight to your opinion?

    The original C style came from Dennis Ritchie's decision several
    decades ago that declaration syntax should imitate use.

    Given:

    int *ip;

    ....then given proper initialization, the expression:

    *ip

    ....is indeed an int.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Mar 29, 2005
    #4
  5. Jack Klein <> writes:
    > On 29 Mar 2005 04:00:17 GMT, Sergei Gnezdov <>
    > wrote in comp.lang.c:
    >> I'd think that
    >>
    >> type* pointerName
    >>
    >> is more descriptive, than
    >>
    >> type *pointerName
    >>
    >> After all, we define a type pointer, not the pointer by itself.

    >
    > Why should we care what you think? What qualifications do you have
    > that we should give weight to your opinion?


    Isn't that a bit harsh? C's declaration syntax, and the conventions
    that go with it, are pretty counterintuitive until you understand the
    reasoning behind them.

    > The original C style came from Dennis Ritchie's decision several
    > decades ago that declaration syntax should imitate use.
    >
    > Given:
    >
    > int *ip;
    >
    > ...then given proper initialization, the expression:
    >
    > *ip
    >
    > ...is indeed an int.


    Agreed. Your followup would have been a good one with that one
    paragraph deleted.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Mar 29, 2005
    #5
  6. >I'd think that
    > type* pointerName
    >is more descriptive, than
    > type *pointerName
    >After all, we define a type pointer, not the pointer by itself.


    This works until you try to declare more than one of them in
    the same declaration.

    type* p1, p2;

    It looks like p1 and p2 are the same type, doesn't it? They're
    not. Now the form you think is more descriptive is more misleading.

    Gordon L. Burditt
     
    Gordon Burditt, Mar 29, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    890
    Roedy Green
    Jan 2, 2006
  2. ding feng
    Replies:
    2
    Views:
    2,904
    ding feng
    Jun 25, 2003
  3. Bobby Chamness
    Replies:
    2
    Views:
    2,440
    Joe Smith
    Apr 22, 2007
  4. Jack-2
    Replies:
    3
    Views:
    327
    Jack-2
    Dec 24, 2003
  5. Java  script  Dude

    IE name="name" & form.name property bug

    Java script Dude, Jun 29, 2004, in forum: Javascript
    Replies:
    5
    Views:
    283
    Java script Dude
    Jun 30, 2004
Loading...

Share This Page