@property

Jacob Carlborg doob at me.com
Sun Aug 5 05:18:48 PDT 2012


On 2012-08-04 22:53, Adam D. Ruppe wrote:

> I did this and now I think this thing is almost done
>
> ===
> int a;
> @property int funcprop() {
>          writeln("calling the getter and getting ", a);
>      return a;
> }
> @property int funcprop(int s) {
>      writeln("calling the setter with ", s);
>      return a = s;
> }
> void main() {
>      funcprop = 40;
>      funcprop += 10;
> }
> ===
>
> run:
>
> calling the setter with 40
> calling the getter and getting 40
> calling the setter with 50
>
> Looks right to me. Now I just have to check for the @property tag on
> some of these rewrites and then clean it up and test for a pull request.

BTW, how will this interact with overloaded operators and similar more 
advanced features? Say that I have a getter that returns a struct/class 
which overloads the += operator.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list