Using opDispatch as *magic* getter/setter. Possible or not?

Steven Schveighoffer schveiguy at yahoo.com
Thu Mar 31 04:31:56 PDT 2011


On Wed, 30 Mar 2011 21:50:43 -0400, spir <denis.spir at gmail.com> wrote:

> On 03/31/2011 02:40 AM, Aleksandar Ružičić wrote:
>> 2011/3/31 Aleksandar Ružičić<ruzicic.aleksandar at gmail.com>:
>>>
>>> Or maybe there is some other way to achive what I want and I'm not
>>> aware of it? :-)
>>>
>>
>> I know I could have used opIndex and opIndexAssign but I really want
>> config.section.entry syntax instead of config["section"]["entry"]...
>
> Agreed. And I would really have an answer to your question, since I  
> tried to do the same thing. Don't understand why D does not have an  
> 'opMember' or 'opDot'. Someone knows?

In fact, opDot exists, but it is superseded by alias this (probably not  
exactly what you are looking for).

opDispatch is exactly what you want, and it should work, but you have to  
jump through the right hoops.

It also has some severe limitations and incorrect implementation (like  
many newer D features).

-Steve


More information about the Digitalmars-d-learn mailing list