Go to the FreeLists Home Page Home Signup Help Login
 



[haiku-development] || [Date Prev] [09-2007 Date Index] [Date Next] || [Thread Prev] [09-2007 Thread Index] [Thread Next]

[haiku-development] Re: Haiku Coding Guidelines Issues

  • From: "Jordan Walsh" <jordanwalsh@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 5 Sep 2007 10:36:54 -0400
I am also not a developer but I keep an eye on the mailing lists. It took me
a long time to get out of the habit of saying "char* foo" rather than "char
*foo" because when i read that line i translate it to "pointer to a
character named foo". It was the way I was taught and has taken some
practice to fix.




On 9/5/07, Truls Becken <truls.becken@xxxxxxxxx> wrote:
>
> On 9/4/07, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx> wrote:
> > > The * for pointers is always located by the variable or method name,
> > > right? There are examples of this, but it isn't spelled out
> > > explicitly. For example:
> > >
> > > class Example {
> > >     public:
> > >         Example();
> > >         ~Example();
> > >
> > >         const char *Name();
> > >
> > >     private:
> > >         BString *fName;
> > > }
> >
> > Actually as OpenBeOS started that was more or less the convention, but
> > since the '*' or '&' belong to the type some people (at least Axel and
> me)
> > consequently sticking it to the type nowadays. According to his sample
> file
> > Michael feels the same, but still has a space between type and '*'.
>
> I'm no Be/Haiku coding standard expert, or even developer, but I still
> want to mention the following. There's a reason why it's considered
> good practice to write * and & next to the variable rather than the
> type. Consider this declaration:
>
>    char* foo, bar;
>
> Intuitively, this should declare two string variables, but the fact is
> that this makes foo a string and bar a character. Grouping the * with
> the variable name makes it more obvious that it modifies the type of a
> single variable only. While this reasoning does not really apply to
> method signatures, it's more consistant to use the same convention for
> both methods and variables.
>
> Regards,
> Truls
>
>


-- 
Jordan Walsh
(910) 639-0111




[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.