override '.' member access

Simen kjaeraas simen.kjaras at gmail.com
Tue Jan 25 16:06:00 PST 2011

spir <denis.spir at gmail.com> wrote:

> On 01/25/2011 10:29 PM, Simen kjaeraas wrote:
>> spir <denis.spir at gmail.com> wrote:
>>> Hello,
>>> Cannot find corresponding opSomething method, if any. (opDispatch  
>>> seems to
>>> specialise for method call.)
>>> Else, how to catch obj.member?
>> opDispatch is likely what you want. with the @property annotation, it
>> will readily support obj.member; and obj.member = foo; syntax.
> Thank you, Simen, i'll try using opDispatch with @property. But I'm not  
> sure how to write that concretely. My use case is of a type holding a  
> string[AnyThing] AA called symbols. Then, I wish to map
> 	obj.id
> to
> 	obj.symbols["id"]
> (hope I'm clear)

I just found that it is, in fact, unpossible. That is, you can support
either a = foo.id; or foo.id = a; - not both. This is caused by bug 620:


More information about the Digitalmars-d-learn mailing list