Ps. Just for kicks, here is a simple ruby 1.8 mock-up of the proposal
(sorry for using ruby, but I don't know enough C to start hacking the
CPython backend; I think that a higher-level example is conceptually
clearer anyhow). Reference cycles are not detected in the example.
#!/usr/bin/ruby
class Object
def method_missing(fun, *args)
begin
TOPLEVEL_BINDING.method(fun).call(self, *args)
rescue
raise(NoMethodError,
%{undefined method `#{fun.to_s}' for "#{self}":String},
[])
end
end
end
def myfun(s1, s2)
s1 + s2
end
puts "foo".myfun("bar")
# -> foobar
puts 1.myfun(2)
# -> 3
puts "foo".nofun("baz")
# -> ./attr_fail.rb:10: undefined method `nofun' for "foo":String
(NoMethodError)
--
http://mail.python.org/mailman/listinfo/python-list