@disable this for structs

Mike Parker aldacron at gmail.com
Fri Feb 28 04:59:32 PST 2014


On 2/28/2014 8:59 PM, Dicebot wrote:
> On Friday, 28 February 2014 at 01:16:41 UTC, Mike Parker wrote:
>> Ideally, I'd love for the compiler to pick up on this idiom and not
>> generate any typeinfo in this situation.
>
> Ideally one should use modules as namespaces :P

I don't buy that. That works fine to resolve conflicts, but it doesn't 
work for fine-grained namespace management. And when using named 
imports, that means everything in the module then belongs to that 
namespace, which isn't at all what I want. Besides which, using either 
fully-qualified names or named imports puts the impetus on the caller. 
If I design my modules around namespaces with the understanding that the 
caller will type foo.bar.myfunc all the time, there are bound to be 
conflicts when they forget to do it.

On the other hand, by wrapping my namespaced stuff in structs or 
classes, I can have multiple namespaces per module, some things 
completely outside the namespace, and the user gets a compiler error if 
they don't use it. To me, that's much, much neater.


More information about the Digitalmars-d-learn mailing list