DIP61: Add namespaces to D
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 26 14:47:07 PDT 2014
On 04/26/2014 08:15 PM, Walter Bright wrote:
> 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.
Nice.
> That's just following existing rules.
>
The example with the mixins does not actually compile. I have filed this:
https://issues.dlang.org/show_bug.cgi?id=12659
More information about the Digitalmars-d
mailing list