Free functions versus member functions

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Thu Oct 11 14:04:34 PDT 2007


BCS wrote:

> Reply to Jari-Matti Mäkelä,
> 
>> 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.
>> 
> As I understand it the difference is that in D you can't access somthing
> without an import. In C++ you can access it, but you need the FQN if you
> don't use using.

Well, yes. But in C++ you still need #include the definition some way first.
The only difference is C++ and D have different kinds of mappings between
namespaces and files. I guess you could get similar behavior by also
extending import to import subscopes inside a module.



More information about the Digitalmars-d mailing list