Intiguing idea. Basically, you could just do it as a keyword:
float value;
accessor inverse(void|float i) { if(query_num_arg()) value=1/i; return 1/value; }
Afterwards any access to 'myvariable' will call the function instead of returning a function pointer, and any assignment will call the same function with a value.
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2003-12-22 21:50: Subject: C#-like properties
Isn't there already a lookup for the variable itself that's O(log(n))? It ought to be possible to device a system where the accessor functions internally are named identically as the identifier they cover, and then there's just some flag test to find out whether it's an accessor function pair or a real variable. If that means that no real variable can be named the same, I wouldn't regard it as a problem (rather the contrary, actually).
/ Martin Stjernholm, Roxen IS