Thread overview
Re: Using opDispatch as *magic* getter/setter. Possible or not?
Mar 31, 2011
spir
March 31, 2011
2011/3/31 Aleksandar Ružičić <ruzicic.aleksandar@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"]...
March 31, 2011
On 03/31/2011 02:40 AM, Aleksandar Ružičić wrote:
> 2011/3/31 Aleksandar Ružičić<ruzicic.aleksandar@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?
This would be one of the first metamethods I would introduce in a language (definitely before operator overloading).

denis
-- 
_________________
vita es estrany
spir.wikidot.com

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

> On 03/31/2011 02:40 AM, Aleksandar Ružičić wrote:
>> 2011/3/31 Aleksandar Ružičić<ruzicic.aleksandar@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