POV-Ray : Newsgroups : povray.off-topic : using namespace : Re: using namespace Server Time
4 Sep 2024 03:18:04 EDT (-0400)
  Re: using namespace  
From: Darren New
Date: 2 Jun 2010 13:17:17
Message: <4c06921d$1@news.povray.org>
Warp wrote:
>   (Since the "namespace bid = boost::io::detail;" ought to be somewhere in
> the beginning of the file or the beginning of the function where it's used,
> it ought to be hard to miss, so it's easy for the reader to know what it
> means.)

I think as long as it's repeated in each source file, that's probably 
useful. If it's buried three #include files deep somewhere in a source file 
with 20+ include files to start with, it might be a little harder to find.

Especially if you write something like

namespace
bid
= boost::io::detail;

(Don't laugh. I've seen this done on the grounds that the definition of an 
identifier always starts at the left edge.)

>> The disadvantages are obvious - having to type bid:: before every type
>> (annoying if almost every line contains several types from that namespace)
> 
>   Do you also use single-character and two-character names for all your
> variables, functions and types so that you have less to type?

I always found the "::" part visually disruptive. It's a shame languages are 
still written to use only ASCII.  I guess with syntax coloring, it's a lot 
easier to skip over the syntactic noise as well.

>   Brevity only leads to obfuscation, ie. it causes the code to be harder
> to understand. 

I'll agree to this. It only helps the author, not the reader, and not even 
the author being the reader six months later.

-- 
Darren New, San Diego CA, USA (PST)
    Ada - the programming language trying to avoid
    you literally shooting yourself in the foot.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.