DIP61: Add namespaces to D
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 26 11:15:09 PDT 2014
On 4/26/2014 5:37 AM, Timon Gehr wrote:
> import std.stdio;
>
> namespace g{
> int foo(int a){ return a; }
> }
> namespace g{
> string foo(string a){ return a; }
> }
>
> void main(){
> writeln(foo(2));
> writeln(foo("a"));
> writeln(g.foo(2));
> writeln(g.foo("a"));
> }
>
> Both examples should still work if the two mixins/namespaces occur in (possibly
> different) imported modules. I think this would be in line with how lookup is
> generally handled in D. (Note that I am not suggesting to make namespaces
> extensible, but rather to make them overloadable.) How do you think about this?
Yes, that's how I anticipate it working. That's just following existing rules.
More information about the Digitalmars-d
mailing list