Hal Fulton wrote:
> I hate to bring up possible language changes, since there is
> so much of that going around.
> 
> Matz, if this is stupid, just tell me so.
> 
> I've sometimes wished for a "break" that would work in (almost) any
> context -- one that would do "the sensible thing" instead of just
> giving an error saying you can't do a break here.
> 
> Two examples are:
> 
> 1. A long string, possibly multiline/multi-statement, is being
> evaled. I want the capability to abort the eval.
> 
> 2. I have a mild dislike for the idiom if $0 == __FILE__ (lines) end
> -- because I always indent inside an if, and I don't want to indent,
> and I really just want to say:  break if $0 != __FILE__
> 
> 
> In both these contexts, I initially tried exit. Of course, that
> doesn't work -- it exits the entire program. A "return" seems like
> the next choice, but that only makes sense within a method.
> 
> There's no proper way to do this kind of thing, as far as I can
> see.

If you just do not want to indent, I would suggest

if $0 == __FILE__
   eval DATA.readlines.join("\n"), binding, __FILE__
end
__END__
puts "HELLO"

It looks ugly and excessive, I agree. It also has problems with error 
reporting, whatever line number it shows you have to add 4 (in this 
particular case) to it mentally.

It works, however ;-)

Gennady.

> 
> Thoughts?
> 
> Hal
> 
>