Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > type* name vs. type *name

Reply
Thread Tools

type* name vs. type *name

 
 
Sergei Gnezdov
Guest
Posts: n/a
 
      03-29-2005
I'd think that

type* pointerName

is more descriptive, than

type *pointerName

After all, we define a type pointer, not the pointer by itself.
 
Reply With Quote
 
 
 
 
Peter MacMillan
Guest
Posts: n/a
 
      03-29-2005
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: http://www.velocityreviews.com/forums/(E-Mail Removed)
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(--)
 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      03-29-2005
In article <(E-Mail Removed)>,
Peter MacMillan <(E-Mail Removed)> 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;

 
Reply With Quote
 
Jack Klein
Guest
Posts: n/a
 
      03-29-2005
On 29 Mar 2005 04:00:17 GMT, Sergei Gnezdov <(E-Mail Removed)>
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/~a...FAQ-acllc.html
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      03-29-2005
Jack Klein <(E-Mail Removed)> writes:
> On 29 Mar 2005 04:00:17 GMT, Sergei Gnezdov <(E-Mail Removed)>
> 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) (E-Mail Removed) <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.
 
Reply With Quote
 
Gordon Burditt
Guest
Posts: n/a
 
      03-29-2005
>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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
print("my name is {name}, and {age}-year old {gender}", name, age, gender); =?iso-8859-1?B?bW9vcJk=?= Java 7 01-02-2006 04:39 PM
IE name="name" & form.name property bug Java script Dude Javascript 5 06-30-2004 03:07 AM
name = name.substring(0, name.lastIndexOf('.')); Help please Jack-2 Javascript 3 12-24-2003 04:39 PM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM



Advertisments