[haXe] New feature : Properties

Nicolas Cannasse ncannasse at motion-twin.com
Thu Apr 13 11:05:31 CEST 2006


> 1. "default" now can't be used safely as a method name (was already a
> keyword?).

Yes, it was and still is a keyword.

> 2. I've had to spent more time than necessary to interpret those 2 line
> (the confusion is that seems that you can just read the value outside
> the class, not inside):
> 
>     *
>       the field |ro| can only be readed outside of the class code
>     *
>       the field |wo| can only be writen outside of the class code
> 
> Isn't that better?
> 
>     *
>       outside the class code, the field |ro| is read only
>     *
>       outside the class code, the field |wo| is write only

Yes :) In general if you think that the way things written on the
website can be expressed better, don't hesitate to register on the Wiki
(Login button) and edit it by yourself !

> 3. Can you use Reflect to access a property? Or has the same restriction
> as Dynamic?

Same restriction, since Reflect is a Dynamic access.

> 4. How do you set a runtinme-generated method for getters/setters?

It's not yet documented, but when you set the "dynamic" accessor, it
will use either get_XXXX or set_XXXX where XXXX is the name of the
property. Additionaly, the compiler will not check that this method
exists (different behavior than if you specified a method), enabling you
to defining it a runtime. For example by using Reflect.setField :

class C {
    public property x(dynamic,null) : Int;
    public function new() { }
}

var c = new C();
Reflect.setField(c,"x",function() { return 33; });
trace(c.x); // 33

Nicolas



More information about the Haxe mailing list