Free functions versus member functions
    Jari-Matti Mäkelä 
    jmjmak at utu.fi.invalid
       
    Thu Oct 11 13:36:55 PDT 2007
    
    
  
Bill Baxter wrote:
> Another difference is that in C++ you have to *explicitly* say you want
> to bring members of a namespace into your current namespace with a
> "using" directive.
> 
> In contrast, D's imports throw all the symbols into the local namespace
> by default.  You have to do something extra to prevent it ("static
> import" instead of import).
I haven't been using C++ lately, but isn't 'using namespace' similar to D
import - it imports all symbols from the namespace. Explicit syntax is
nameSpace::symbol IIRC.
> "Using" is also a nice tool for manipulating visibility of namespaces.
> D doesn't have anything quite like it.   You can say at the function
> level for instance "using SomeNamespace" and then you can use things
> from that namespace unqualified, but just to the end of that function.
> There's also a renamed using -- something like "using SNS =
> SomeNamespace;" I think.
Well isn't this what has been proposed for D already, i.e. imports inside
non-module level scopes.
    
    
More information about the Digitalmars-d
mailing list