Re: [Flightgear-devel] using std::

2008-07-31 Thread Erik Hofman
Tim Moore wrote:
> To add my two cents:
> I mostly favor putting "using" declarations at the top of source files 
> instead 
> of using namespace qualifiers in the code. On the other hand, I would 
> probably 
> use the namespace qualifer explicitly if the symbol in question is somewhat 
> obscure, to give the reader a clue about its source. For example, I'd never 
> type 
> std::string in code, but would probably type std::nth_element.
> 
> A middle ground, considered the best C++ style by many, is to explicitly use 
> only the symbols you are referencing from a namespace, instead of using the 
> whole namespace. This is a style and taste issue, best left to the individual 
> developer and circumstances. Personally, I have typed "using namespace osg;" 
> almost everywhere that there is a reference to Open Scene Graph symbols 
> because 
> there is a tendency to use many symbols from that namespace at once, but my 
> thinking is now leaning towards explicit "using" declarations for individual 
> symbols instead.

This is pretty much in line with the rest, excellent.
Just a note to the developers, this is *not* a regulation but rather a 
guideline.

Erik


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-31 Thread Tim Moore
Erik Hofman wrote:
> James Turner wrote:
> 
>> I think this is a good example of why 'using std::xxx' is potentially  
>> problematic in headers (especially public library headers, i.e  
>> Simgear), but fine in sources. So if I'm doing future cleanups, that's  
>> the approach I'd take - remove 'using' from headers, and add it to  
>> sources, unless there's only one or two uses, in which case I'll use a  
>> std:: prefix.
>>
>> Equally, I'm pretty sure people avoid calling things 'string' or  
>> 'vector' for exactly these reasons, so it's 99.9% unnecessary, as  
>> Melchior said.
>>
>> Does this seem reasonable?
> 
> Seems good to me.
To add my two cents:
I mostly favor putting "using" declarations at the top of source files instead 
of using namespace qualifiers in the code. On the other hand, I would probably 
use the namespace qualifer explicitly if the symbol in question is somewhat 
obscure, to give the reader a clue about its source. For example, I'd never 
type 
std::string in code, but would probably type std::nth_element.

A middle ground, considered the best C++ style by many, is to explicitly use 
only the symbols you are referencing from a namespace, instead of using the 
whole namespace. This is a style and taste issue, best left to the individual 
developer and circumstances. Personally, I have typed "using namespace osg;" 
almost everywhere that there is a reference to Open Scene Graph symbols because 
there is a tendency to use many symbols from that namespace at once, but my 
thinking is now leaning towards explicit "using" declarations for individual 
symbols instead.

Tim


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-30 Thread Melchior FRANZ
* Melchior FRANZ -- Wednesday 30 July 2008:
> Yes, I undestood the situation and the question perfectly well.

Argh, no, I didn't. I missed the "headers" part. Of course I
agree on that -- that's evil. Sorry for the redundant noise
then.  ;-)

m.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-30 Thread Erik Hofman
James Turner wrote:

> I think this is a good example of why 'using std::xxx' is potentially  
> problematic in headers (especially public library headers, i.e  
> Simgear), but fine in sources. So if I'm doing future cleanups, that's  
> the approach I'd take - remove 'using' from headers, and add it to  
> sources, unless there's only one or two uses, in which case I'll use a  
> std:: prefix.
> 
> Equally, I'm pretty sure people avoid calling things 'string' or  
> 'vector' for exactly these reasons, so it's 99.9% unnecessary, as  
> Melchior said.
> 
> Does this seem reasonable?

Seems good to me.
Thanks for the work.

Erik

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-30 Thread James Turner

On 30 Jul 2008, at 13:23, Melchior FRANZ wrote:

> Actually, I think that putting std:: at every reference is
> not preferable, as in 99% of the cases we mean std::string,
> and in 100% we mean std::cout, so the prefix is basically
> redundant noise. Do we actually have more than one or two
> cases where a name by itself would look ambiguous? I'm only
> aware of ./src/GUI/AirportList.cxx, where "string" would be
> considered a pu-member without the std.

I think this is a good example of why 'using std::xxx' is potentially  
problematic in headers (especially public library headers, i.e  
Simgear), but fine in sources. So if I'm doing future cleanups, that's  
the approach I'd take - remove 'using' from headers, and add it to  
sources, unless there's only one or two uses, in which case I'll use a  
std:: prefix.

Equally, I'm pretty sure people avoid calling things 'string' or  
'vector' for exactly these reasons, so it's 99.9% unnecessary, as  
Melchior said.

Does this seem reasonable?

James

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-30 Thread Melchior FRANZ
* Erik Hofman -- Wednesday 30 July 2008:
> Melchior FRANZ wrote:
> > * Erik Hofman -- Wednesday 30 July 2008:
> > IOW: Leave it to the developer.
> 
> Well I got some patches from James that turned 'using std::'
> into std::, hence the question. 

Yes, I undestood the situation and the question perfectly well.
The original author chose one of the possible versions, and
James submitted a patch to change them all according to a
(not yet existing) policy. And I'm against a policy in this
matter.

Actually, I think that putting std:: at every reference is
not preferable, as in 99% of the cases we mean std::string,
and in 100% we mean std::cout, so the prefix is basically
redundant noise. Do we actually have more than one or two
cases where a name by itself would look ambiguous? I'm only
aware of ./src/GUI/AirportList.cxx, where "string" would be
considered a pu-member without the std.

But then again, I don't really have a strong preference.

m.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-30 Thread Erik Hofman
Melchior FRANZ wrote:
> * Erik Hofman -- Wednesday 30 July 2008:
>> To continue this discussion a bit (please add your comments) James an I 
>> had a short discussion about using std::string (for example) everywhere 
>> in the file or using " using std::string;" at the beginning.
> 
> I think this shouldn't be a policy question at all. Sometimes one
> "using std::string" for the whole file makes the most sense,
> sometimes it makes more sense to have that in only the few
> functions that need it, and sometimes an explicit namespace
> prefix per access seems preferable.
> 
> IOW: Leave it to the developer.

Well I got some patches from James that turned 'using std::' into std::, 
hence the question. In this case someone else is changing it rather than 
the developer himself.

Erik

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-30 Thread Melchior FRANZ
* Erik Hofman -- Wednesday 30 July 2008:
> To continue this discussion a bit (please add your comments) James an I 
> had a short discussion about using std::string (for example) everywhere 
> in the file or using " using std::string;" at the beginning.

I think this shouldn't be a policy question at all. Sometimes one
"using std::string" for the whole file makes the most sense,
sometimes it makes more sense to have that in only the few
functions that need it, and sometimes an explicit namespace
prefix per access seems preferable.

IOW: Leave it to the developer.

m. 

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] using std::

2008-07-30 Thread James Turner

On 30 Jul 2008, at 11:29, Erik Hofman wrote:

> To continue this discussion a bit (please add your comments) James  
> an I
> had a short discussion about using std::string (for example)  
> everywhere
> in the file or using " using std::string;" at the beginning. James
> pointed out that the suing std:: statement in header files might not  
> be
> a good idea, but to my opinion it improves readability by using it in
> the .cxx files rater that spreading std::string across the file.
>
> Any comments on this?
>
> I tend to go for using std:: in the .cxx files unless it is for one or
> two references in the code.

And to point out, I was biased due to contributing lots in the past to  
a project with some C++ uh, pedants, who regarding 'using' as very  
particular tool, not something to save some typing.

I am pretty much convinced by Erik's argument that in source files, if  
it's more than a couple of usages, a 'using std::foo' is fine and  
sensible.

James

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


[Flightgear-devel] using std::

2008-07-30 Thread Erik Hofman

To continue this discussion a bit (please add your comments) James an I 
had a short discussion about using std::string (for example) everywhere 
in the file or using " using std::string;" at the beginning. James 
pointed out that the suing std:: statement in header files might not be 
a good idea, but to my opinion it improves readability by using it in 
the .cxx files rater that spreading std::string across the file.

Any comments on this?

I tend to go for using std:: in the .cxx files unless it is for one or 
two references in the code.

Erik


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel