From: "T. Onoma" Date: 2003-11-23T12:46:05+09:00 Subject: Cascading class definitions effect objects I'm doing some hard nosed analysis of AOP for Ruby (:pre, :wrap, etc.) as this is a feature I am most concerned with in Ruby2. I am troubled by the follwoing code: class CookieCutter def eat puts "Yum!" end end cookie = CookieCutter.new cookie.eat # => Yum! class CookieCutter def eat puts "Yuk!" end end cookie.eat # => Yuk! Is it right to have substantiated objects modifiable on the fly by redefinitions of their class? Do you know of any program that actually utilizes this? Ruby is *really* dynamic, perhaps a little too so. This seems exceptionally odd. I have never noticed this behaivor before, and I imagine most people do not b/c they *always define their classes before using them*. Analogous to the real world: when I make a cookie with a cookiecutter, all my previous cookies do magically change because I later change my cookiecutter. So I would expect that cookie would always be like CookieCutter class as it was when cookie was constructed. And that the only way to change cookie after that would be through singletons and extend. (And have remove_singleton and unextend too.) This has big impact on AOP, duck typing and InterfaceContracts, as well. -t0