Jonas Drewsen Wrote:

> Just tried the property stuff out but it seems a bit inconsistent. Maybe 
> someone can enlighten me:
> 
> import std.stdio;
> 
> alias void delegate() deleg;
> 
> class T {
>    private deleg tvalue;
>    @property void prop(deleg dg) {
>      tvalue = dg;
>    }
>    @property deleg prop() {
>      return tvalue;
>    }
> }
> 
> void main(string[] args) {
>    T t = new T;
>    t.prop = { writeln("fda"); };
> 
>    // Seems a bit odd that assigning to a temporary (tvalue) suddently
>    // changes the behaviour.
>    auto tvalue = t.prop;
>    tvalue();     // Works as expected by printing fda
>    t.prop();     // Just returns the delegate!
> 
>    // Shouldn't the @property attribute ensure that no () is needed
>    // when using the property
>    t.prop()(); // Works
> }
> 
> /Jonas

Ah, yes. One of the big reasons for introducing @property was because returning 
delegates could be very confusing in terms if whether the delegate is called or 
returned from the function. Since the old system has not yet been ripped out 
@property basically does nothing except under some conditions where it will 
complain you have added a ().

So the situation should improve, but I really don't know how or when things 
will change.

Reply via email to