@autocall aka property for the millionth time

Timon Gehr timon.gehr at gmx.ch
Thu Jul 4 08:37:40 PDT 2013


On 07/04/2013 05:26 PM, Adam D. Ruppe wrote:
> I have one more solution to the property situation. This punts much of
> it to the library, but is actually easy to implement - I just added a
> proof of concept to a devel dmd in about 15 minutes.
>
> Overview:
>
> 1) this is purely additive, changing nothing with existing code. Those
> are separate debates that I don't want to go over again.
>
> 2) Add an attribute @autocall that can be attached to functions. If an
> @autocall function is ever mentioned anywhere, in any context, it is
> rewritten foo -> foo().
>
> Given that rewrite, it doesn't make sense for @autocall functions to
> take any arguments, since it is impossible to pass it any.
>
> 3) The rest of the details in making properties work are done by
> returning ref and/or helper structs.
> ...

Doesn't work with type deduction.

What about keeping @property for setters and using @autocall for getters 
to get rid of all the ambiguity?



More information about the Digitalmars-d mailing list