At 12:14 PM 5/1/2007 -0700, Guido van Rossum wrote: >Suppose you couldn't assign to __class__ of a function (that's too >messy to deal with in CPython) and you couldn't assign to its __code__ >either. What proposed functionality would you lose?
The ability to overload any function, without having to track down all the places it's already been imported or otherwise saved, and change them to point to a new function or a non-function object. >How would you >ideally implement that functionality if you had the ability to modify >CPython in other ways? (I'm guessing you'd want to add some >functionality to function objects; what would that functionality have >to do?) Hm... well, in PyPy they have a "become" feature (I don't know if it's a mainline feature or not) that allows you to say, "replace object A with object B, wherever A is currently referenced". Then the replacement object (GF implementation) needn't even be a function. A narrower feature, however, more specific to functions, would just be *some* way to redirect or guard the function's actual execution. For example, if function objects had a writable __call__ attribute, that would be invoked in place of the normal behavior. (Assuming there was a way to save the old __call__ or make a copy of the function before it was modified.) I really just need a way to make calling the function do something different from what it normally would -- and ideally this should be in such a way that I could still invoke the function's original behavior. (So it can be used as the default method when nothing else matches, or the least-specific fallback method.) _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
