Static attributes & immutability, static attributes seen from instances

Adam D. Ruppe destructionator at gmail.com
Sat Mar 6 08:30:45 PST 2010


On Sat, Mar 06, 2010 at 11:33:02AM +0000, Michal Minich wrote:
> This would allow an additional feature: two "namespaces" in the class/
> struct - one for static names and one for instance names, giving ability 
> to "overload" members - i.e. have two opCall in struct - one for type and 
> one for instance. But I cannot think of any example use case of this 
> feature right now.

I'd really like for opCall to be separated out, so you can initialize 
structs from various types and treat it like a function object without
hassle. I've tried to do this now, but it keeps calling static opcall when
I wanted the other one, and sometimes vice versa.

In a perfect world, all three of these would be workable:

Variant a = 10;
Variant b = { writefln("Hello, world!"); };
b();

But, last time I tried, I could get line 2 or line 3 to work, but not both.
Separating static from instance should do the trick.


-- 
Adam D. Ruppe
http://arsdnet.net



More information about the Digitalmars-d mailing list