If I understand you correctly, your `= lfun would imply that an assignment to a variable becomes dependent on the old value in it. That's not something I'd expect of an assignment; in my view an assignment operates on a variable, not the value in it. It'd make objects too slippery for my taste:
object x = a_fishy_object; ... x = a_nice_object; if (x->is_fishy_object) { werror ("Foo?\n"); x = 0; // Begone! if (objectp (x) && x->is_fishy_object) { werror ("Arrgh!\n"); destruct (x); // Die, sucker! } }
If lfuns could be added to variables then a `= would make sense.
Anyway, how would such a thing help simulating pass-by-reference on the calling side? Where would the object instance with the `= come from?
/ Martin Stjernholm, Roxen IS
Previous text:
2003-04-16 02:02: Subject: Pointers/lvalues
My idea is that if an object has a `= lfun it will be called with the assignment value for the variable and gets the actual value to assign in return. Creating a secure string variable could be based on code along the following lines:
class HiddenString { string hidden; this_program `=(mixed x) { if(stringp(x)) { hidden=x; return this_object(); } return x; } }
/ Martin Nilsson (har bott i google)