property syntax strawman
Michiel Helvensteijn
m.helvensteijn.remove at gmail.com
Sun Aug 2 08:07:26 PDT 2009
JPF wrote:
> There's at least one more solution:
> define the property as
> --------------------------------------------------
>>> bool empty {
>>> void set(auto value) { ... }
>>> auto get() { ... }
>>> }
> --------------------------------------------------
> but rewrite empty.get/set to empty.__get/__set. As far as I know names
> beginning with __ are reserved, so the returned type of the property
> couldn't define it.
This may be acceptable. I don't much like that the double-underscore is
necessary, but it may be the best solution there is.
> auto getter = &empty.__get()
You meant without the parentheses here, right?
> As an addition
> --------------------------------------------------
> auto b = &empty
> --------------------------------------------------
> would then return a pointer to the returned value.
That would be a pointer to a temporary value, though. Not very useful. But
lexically, it works, yes.
--
Michiel Helvensteijn
More information about the Digitalmars-d
mailing list