From: "Haase, Konstantin" Date: 2011-06-07T17:14:00+09:00 Subject: [ruby-core:36807] Re: [Ruby 1.9 - Feature #4840][Open] Allow returning from require How will that work with require? Remember it will only load the file once. Return false otherwise? (Which would be kinda compatible with the current behavior and using raise/throw). Or should those values be cached? If you want to use require CommonJS-style, it has to be cached. But what about return values that depend on or provoke side effects? Should files support early return? Konstantin On Jun 7, 2011, at 00:08 , Clifford Heath wrote: > On 07/06/2011, at 12:18 AM, Michael Edgar wrote: >> On Jun 6, 2011, at 10:11 AM, Rodrigo Rosenfeld Rosas wrote: >>> It would be great to allow return from a required file or some >>> other keyword (break, etc or a new one) >> >> This could be implemented as a method that raises an exception that >> `require` and `load` rescue. >> I'm not sure how compatible that would be with custom require >> implementations (rubygems, >> polyglot, etc) > > Polyglot will pass all exceptions except LoadError (or a subclass). > With a LoadError, if it has no further possibility to satisfy the > require, > the original exception is re-raised. Thus, polyglot should not impede > the implementation you propose. > > Clifford Heath. >