On Thursday, October 7, 2004, 7:09:10 PM, Brian wrote: > I suppose Ruby could make finding these problems much easier if there were a > way of distinguishing a method end, and a class/module end, from a block > end: > class Foo > def m1 > ... > enddef # ? > ... > endclass # ? Yeah, but that's ugly :) > 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" > Sprinkling a few "method_boundary" and "class_boundary" statements at > strategic points in a file would easily localise the problems. I wonder if > there is a clever way to implement this directly in Ruby? To localise the problem, I use % in Vim to jump between "end" and the corresponding "class", "if", "def", ... statement. Doesn't take long to find the sucker, usually. Gavin