>      @before(do_stuff)
>      def debug_it(ob: ClassC):
>          import pdb
>          pdb.set_trace()

This is probably far fetched, but I would much rather see:

       before do_stuff(ob: ClassC):
           import pbd
           pdb.set_trace()

So the keyword 'before' and 'after' are just like 'def', they define 
functions with a particular signature that get inserted into the "which 
function to call" execution sequence.

I would want to be able to reference functions within classes as well:

       >>> class A:
       ...     def f(self, x):
       ...         print 'A.f, x =', x
       ...
       >>> z = A()
       >>> z.f(1)
       A.f, x = 1
       >>>
       >>> before A.f(self, x):
       ...     print 'yo!'
       ...
       >>> z.f(2)
       yo!
       A.f, x = 2

Could the sequence of opcodes for the 'before f()' get mushed into the 
front of the existing code for f()?  That would mean that changes to 'x' 
would be reflected in the original f():

       >>> before A.f(self, x):
       ...     print 'doubled'
       ...     x = x * 2
       >>> z.f(3)
       doubled
       yo!
       A.f, x = 6

And does a 'return' statement from a before short-circuit the call, or 
should it mean the same thing as falling off the end?


Joel
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to