Pseudo namespaces

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 4 12:14:40 PST 2015


Jacob Carlborg <doob at me.com> wrote:
> On 2015-12-04 15:00, Andrei Alexandrescu wrote:
> 
>> How would one create a module inside a class or struct? -- Andrei
> 
> Hmm, I see that I really didn't understand what you were trying to do. 
> So you want to create a namespace inside a class or struct? I would 
> probably create a separate struct and return that from a function
> 
> struct List(T)
> {
>     static struct Stable
>     {
>         void fun(int x) { }
>     }
>     auto stable() { return Stable(); }
> }
> 
> List!(int) list;
> 
> list.stable.fun(2);
> 

Won't work. Fun has no access to the list.



More information about the Digitalmars-d mailing list