On Thu, Oct 07, 2004 at 06:18:35PM +0900, Gavin Sinclair wrote: > > Being forced to write that could be annoying too. But actually, just having > > a way to test at compile time whether you're outside a method call, or > > outside a class definition, would be good enough for me: > > > class Foo > > def m1 > > "foo" > > end > > method_boundary <-- raise error if inside 'def' > > method_boundary := "raise unless self == Foo" > > or (more general) > > method_boundary := "raise unless Class === self" That doesn't work, because if it occurs within a method definition, it doesn't get executed; it just gets compiled as part of the method. class Foo def m1 if 1 == 2 puts "Bad" end raise unless Class === self # nothing happens end Regards, Brian.