None taken.
You are not the first to suggest that I am looking for something different and incompatible. I say that I am not. I want everything that an lvalue sub or method has now in p5 (actually more as I would like for list context lvalue subs to work properly). The only difference is that I would like to be able to validate the assignment.
One of the reasons given for why the this is not possible without resorting to callbacks in the form of a tie, is that it would make localising (temporising) lvalue subs difficult or impossible.
The term "temporise", and all discussion relating to it, comes directly from Apocalypse 6.
But in particular, note that we want to be able to temporize object attributes, which is why there's a TEMP method in our proxy. In Perl 5 you could only temporize (localize) variables. But we want accessors to be usable exactly as if they were variables, which implies that temporization is part of the interface. When you use a temp or let context specifier:
temp $obj.foo = 42;
let $obj.bar = 43;
the proxy attribute returned by the lvalue method needs to know how to temporize the value. More precisely, it needs to know how to restore the old value at the end of the dynamic scope.
All I did was fall in line with the terminology used there.
It was suggested that the ability to localise (temporise) an lvalue sub for a scoped duration was one reason why if any validation was allowed for lvalue subs, it would have to be done as a callback (via tie or similar).
The post to which you replied and it's predecessor describe my suggestion that it would be better to localise the sub itself and a temporary lvalue, rather than the actual lvalue returned by the sub.
In terms of the above snippet, the value assigned in temp $obj.foo = 42; would be "undone" at the end of the scope. In this case, by temporising the sub rather than fetching real lvalue, the end of scope would simply discard the temporary value assigned.
The only time the real sub would get called is if the temporary value is made real as in the let $obj.bar = 43;
Assuming I've understood the terminiology. FWIW: I now see the flaw in this suggestion.
Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
|