It could be combined with variants, perhaps:
variant accessor float inverse() { return 1/value; } variant accessor void inverse (float i) { value = 1/i; }
Another syntax that makes it look even more like a cross between a variable and a function declaration:
float inverse // Note: Not function arglist at all. { return 1/value; }
void inverse = float i { value = 1/i; }
I think it can be fit into the parser without ambiguities, but I'm not sure.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-12-22 22:56: Subject: C#-like properties
accessor inverse(void|float i)
^^^^^^^
Afterwards any access to 'myvariable' will call the function instead
^^^^^^^^^^
'inverse' I hope?
It's excellent except that I would like syntactic sugar for get instead of counting arguments...
But that would/could coincide with something else, default values.
accessor inverse(float i=value) { ... }
where i gets the default value of value if not set. (I suggested this a long time ago.)
/ Mirar