Properties no longer work?

BCS BCS at pathlink.com
Thu Jul 27 10:08:46 PDT 2006


Jarrett Billingsley wrote:
> "Hasan Aljudy" <hasan.aljudy at gmail.com> wrote in message 
> news:ea6fsm$2lb6$1 at digitaldaemon.com...
> 
>>Did properties stop working?
>>
>>assuming object abc has a method foo:
>># auto x = abc.foo;
>>gives a compiler error: x cannot be a function (or something like that)
> 
> 
> Stop using type inference.  ;)
> 
> int x = abc.foo;
> 
> When you write "abc.foo" as the initializer for a type-inferenced 
> declaration, it tries to deduce the type of the declaration before 
> converting the property access to a function call.  Thus, it thinks you're 
> trying to create a variable x with the same type as abc.foo; i.e. a function 
> type (not a function pointer, just a function), which is illegal.  This 
> might be a bug, but it's been around for a while, and not just since 0.163. 
> 
> 

It gets worse. If foo is overloaded, then DMD silently grabs the 
lexically first version and uses it. This is in direct contradiction of 
the idea that lexical order of functions/classes/etc. should not effect 
semantics. (I seem to recall that this is one of the goals of D, but I 
can't find the reference).



More information about the Digitalmars-d-learn mailing list