Issue #4840 has been reported by Rodrigo Rosenfeld Rosas. ---------------------------------------- Feature #4840: Allow returning from require http://redmine.ruby-lang.org/issues/4840 Author: Rodrigo Rosenfeld Rosas Status: Open Priority: Normal Assignee: Category: Target version: I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2011-06-06 16:12
on 2011-06-06 16:19
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), but it would obviate the need for a new keyword or commandeering an existing one. Michael Edgar adgar@carboni.ca http://carboni.ca/
on 2011-06-06 17:01
I think using "return" is quite natural in this case, as long as we can use it in module/class-definitions too. // Magnus Holm
on 2011-06-07 00:09
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.
on 2011-06-07 10:14
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 2011-06-07 12:10
Hello, 2011/6/6 Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>: > #tons of lines here > > It would be great to allow return from a required file or some other keyword (break, etc or a new one) Agreed. It would be also useful to write platform-specific code: require "test/unit" return unless /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM class TestForWindowsEnv < Test::Unit::TestCase ... Here is an experimental patch: diff --git a/compile.c b/compile.c index 10d63bc..7b9c490 100644 --- a/compile.c +++ b/compile.c @@ -4291,10 +4291,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) rb_iseq_t *is = iseq; if (is) { - if (is->type == ISEQ_TYPE_TOP) { - COMPILE_ERROR((ERROR_ARGS "Invalid return")); - } - else { LABEL *splabel = 0; if (is->type == ISEQ_TYPE_METHOD) { @@ -4321,7 +4317,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) ADD_INSN(ret, nd_line(node), pop); } } - } } break; } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index f40dfdf..274f45d 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1561,8 +1561,6 @@ vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp, cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } - rb_vm_localjump_error("unexpected return", throwobj, TAG_RETURN); - valid_return: pt = dfp; }
on 2011-06-07 13:15
Em 07-06-2011 07:10, Yusuke ENDOH escreveu: >> > return unless /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM > --- a/compile.c > LABEL *splabel = 0; > } > valid_return: > pt = dfp; > } > This patch is so small, that it seems strange that it affects only requires... Won't it have side effects? Notice that I didn't test it yet. I agree with you about specific-platform tests use case too. Thanks for your interest, Rodrigo.
on 2011-06-07 13:20
Em 07-06-2011 05:14, Haase, Konstantin escreveu:
> 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?
I was thinking about that yesterday, but I have no idea how this should
work. If an aborted required should return true or false. Or a value
defined by the return, like:
return :aborted if should_abort?
Or if require should accept some block as:
require('some/file'){|return_value| do_something_with return_value }
Really, I have no idea about this!
Best regards,
Rodrigo.
on 2011-06-07 13:37
Hello, 2011/6/7 Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>: > This patch is so small, that it seems strange that it affects only > requires... Won't it have side effects? Notice that I didn't test it yet. I'm not sure. But surprisingly, the patch passes all tests except one.
on 2011-06-08 02:33
Hi,
In message "Re: [ruby-core:36811] Re: [Ruby 1.9 - Feature #4840][Open]
Allow returning from require"
on Tue, 7 Jun 2011 19:10:15 +0900, Yusuke ENDOH <mame@tsg.ne.jp>
writes:
|Agreed.
Ah, I understand the request. But returning from outside of a method
makes me so weird.
matz.
on 2011-06-08 09:38
On Tue, Jun 7, 2011 at 7:33 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote: > Ah, I understand the request. But returning from outside of a method > makes me so weird. I agree with both the feature and the fact that return outside a method feels weird. An early termination of a loading file would be welcome; I've wanted this many times, and always ended up doing the super-gross "giant if" to accomplish what could be done by a simple early exit. I wonder if a core method that does the early return would be a better option, like Kernel#exit_script. It could be implemented to throw an exception all requires and loads expect to catch, like "ExitScriptError" or something. That would seem more consistent than having return end the script...but not actually be returning anything. Another option would be to use a different keyword that isn't so tied to method/proc bodies, like "break" break if defined? GitoriousConfig I think I like the exit_script version better, though. exit_script if defined? GitoriousConfig - Charlie
on 2011-06-08 10:44
On Wed, Jun 8, 2011 at 8:38 AM, Charles Oliver Nutter <headius@headius.com>wrote: > exit_script if defined? GitoriousConfig > This could be confusing, if you happen to view the entire program as a script. You might think that "exit_script" will do the same thing as "abort". I like the idea, though.
on 2011-06-08 11:23
On Jun 7, 2011, at 17:33 , Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:36811] Re: [Ruby 1.9 - Feature #4840][Open] Allow returning from require" > on Tue, 7 Jun 2011 19:10:15 +0900, Yusuke ENDOH <mame@tsg.ne.jp> writes: > > |Agreed. > > Ah, I understand the request. But returning from outside of a method > makes me so weird. How about raising a specific exception that is rescued by #require instead? class AbortRequire < StandardError; end alias :original_require :require def require f original_require f rescue AbortRequire false end def p require 'f' # => false # f.rb: raise AbortRequire if defined? GitoriousConfig
on 2011-06-08 11:24
On Wed, Jun 8, 2011 at 4:22 AM, Ryan Davis <ryand-ruby@zenspider.com> wrote: > How about raising a specific exception that is rescued by #require instead? > > class AbortRequire < StandardError; end ... > raise AbortRequire if defined? GitoriousConfig That's pretty clean too. Name needs work ;) I almost suggested a special catch tag that all requires wrap, but catch/throw is a little arcane for most folks... - Charlie
on 2011-06-08 13:57
On 08/06/11 01:33, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:36811] Re: [Ruby 1.9 - Feature #4840][Open] Allow returning from require" > on Tue, 7 Jun 2011 19:10:15 +0900, Yusuke ENDOH <mame@tsg.ne.jp> writes: > > |Agreed. > > Ah, I understand the request. But returning from outside of a method > makes me so weird. To me, return would imply that the returned value should be passed back by the original require call, like so: $ cat a.rb return 42 $ cat b.rb p require("a") $ ruby -I. b.rb 42 That could be *really* handy, although it's not compatible with my previous suggestion (currently languishing here: http://redmine.ruby-lang.org/issues/4523 - any comments?). An already-loaded file can still be signaled by a nil return value, and a file could pretend to be already loaded (if that's at all useful) by choosing nil as its return value... Food for thought :-)
on 2011-06-08 14:00
One real use case I see would be avoiding global state (like CommonJS). However, if an already required file return nil, this is not possible.
on 2012-03-25 09:10
Issue #4840 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-25132 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2012-03-25 17:07
Issue #4840 has been updated by trans (Thomas Sawyer).
I've had occasion to use this as well, especially for RUBY_VERSION
specific code.
I wonder if it is okay to be embedded in other code though. Would this
work?
class Q
def foo
exit_script
end
end
Q.new.foo
Is it a good idea for it to work? Or should exit_script only be allowed
at toplevel?
----------------------------------------
Feature #4840: Allow returning from require
https://bugs.ruby-lang.org/issues/4840#change-25169
Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:
I have a situation where there is some code in Gitorious like:
unless defined? GitoriousConfig
# tons of lines here
end
And I would it to look like
return if defined? GitoriousConfig
#tons of lines here
It would be great to allow return from a required file or some other
keyword (break, etc or a new one)
on 2012-06-07 19:38
Issue #4840 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas). File feature-4840.odp added ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-27072 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2012-06-08 01:01
Issue #4840 has been updated by mame (Yusuke Endoh). Received. Thanks for quick action! But, matz said "returning from outside of a method makes me so weird" once. I'm ok if you want to give it a second try with no change, but I guess matz is not likely to accept it for the same reason. (Well, but, maybe it isn't so bad way because he sometimes changes his mind) -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-27081 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2012-06-08 14:52
Issue #4840 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas). thanks for worrying, but I'll take the risk :) ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-27098 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2012-07-23 15:12
Issue #4840 has been updated by mame (Yusuke Endoh).
Rodrigo Rosenfeld Rosas,
At the developer meeting (7/21), Matz was basically positive
to this proposal, but it turned out that we still need to
discuss corner cases.
Here is a discussion summary.
* Matz said that he will accept "return from toplevel", but
that reject "return from class definition".
return if cond # OK
class Foo
return if cond # NG
end
* "return from toplevel" should always discard the argument.
* What's happen if it returns from the start script (the given
script to interpreter as a cmdline)?
- The argument should be discarded; it does NOT affect the
process termination status code
- The same as "exit", but cannot rescue SystemExit
* What's happen in the following corner cases?
- eval("return") in toplevel
- proc { return }.call in toplevel
* Matz prefered "return" to "a special exception that require
and load rescue",
- though some people (including ko1) prefered the latter.
--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Feature #4840: Allow returning from require
https://bugs.ruby-lang.org/issues/4840#change-28309
Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:
I have a situation where there is some code in Gitorious like:
unless defined? GitoriousConfig
# tons of lines here
end
And I would it to look like
return if defined? GitoriousConfig
#tons of lines here
It would be great to allow return from a required file or some other
keyword (break, etc or a new one)
on 2012-07-23 16:57
Em 23-07-2012 10:12, mame (Yusuke Endoh) escreveu: > Here is a discussion summary. > > * Matz said that he will accept "return from toplevel", but > that reject "return from class definition". > > return if cond # OK > class Foo > return if cond # NG > end Totally agree. > * "return from toplevel" should always discard the argument. You mean "return something", right? I agree. Maybe we could even issue an exception if anything other than just "return" is used. > * What's happen if it returns from the start script (the given > script to interpreter as a cmdline)? > > - The argument should be discarded; it does NOT affect the > process termination status code > > - The same as "exit", but cannot rescue SystemExit Agreed. Specifically "return" should be equivalent to "exit 0", right? And "return -1" (or any other value, including 0) shouldn't be allowed in my opinion, raising an exception, in which case the return value wouldn't be 0 obviously :) > * What's happen in the following corner cases? > > - eval("return") in toplevel I'd vote for just abandoning any subsequent code in the eval and nothing else. Maybe for that case "return" could use the arguments for the result of "eval". > - proc { return }.call in toplevel If it is the main program, "exit" would be the equivalent. Otherwise, no code would be interpreted after the "call" call. I don't understand what makes this so special. > * Matz prefered "return" to "a special exception that require > and load rescue", > > - though some people (including ko1) prefered the latter. I'm okay with raising an exception that would be rescued by require, require_relative and load. Actually I guess this is the simpler approach and it fulfills all the real use cases I could think of in this moment.
on 2012-07-23 17:45
Issue #4840 has been updated by alexeymuranov (Alexey Muranov). How about redefining `__END__` to allow to call it as a method? ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-28338 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2012-07-24 03:26
(2012/07/24 0:44), alexeymuranov (Alexey Muranov) wrote: > > How about redefining `__END__` to allow to call it as a method? It has compatibility issue that __END__ is related to DATA.
on 2012-07-24 03:38
(2012/07/23 23:57), Rodrigo Rosenfeld Rosas wrote: >> >> - The same as "exit", but cannot rescue SystemExit > > Agreed. Specifically "return" should be equivalent to "exit 0", right? > And "return -1" (or any other value, including 0) shouldn't be allowed > in my opinion, raising an exception, in which case the return value > wouldn't be 0 obviously :) matz proposed that ignore return argument completely. matz also said to avoid mistake, return expression with argument (example: "return foo") should be syntax error. >> - proc { return }.call in toplevel > > If it is the main program, "exit" would be the equivalent. Otherwise, no > code would be interpreted after the "call" call. > > I don't understand what makes this so special. (1) pr = proc{return} def foo(pr) pr.call # what happen? end (1') 1.times{ return } (2) # a.rb $pr = proc{return} # b.rb require './a.rb' $pr.call # waht happen? (3) begin ... rescue return ensure return end matz proposed that "accept return on toplevel (not in block, classes, etc)". >> * Matz prefered "return" to "a special exception that require >> and load rescue", >> >> - though some people (including ko1) prefered the latter. > > I'm okay with raising an exception that would be rescued by require, > require_relative and load. > > Actually I guess this is the simpler approach and it fulfills all the > real use cases I could think of in this moment. I strongly recommended the exception approach because there are *NO* difficult corner cases. However, matz disagreed the exception approach because of "raise StopLoading is too long". It is a kind of "name is not good".
on 2012-07-24 04:43
>> How about redefining `__END__` to allow to call it as a method? > > It has compatibility issue that __END__ is related to DATA. Then what about `__end__`? Tangentially, why not deprecate __END__? Is there some really important use case that we just can't live without? The whole idea strikes me as rather hackish, especially considering it is limited to main file.
on 2012-07-24 04:47
Em 23-07-2012 22:37, SASADA Koichi escreveu: >>> >>> - The same as "exit", but cannot rescue SystemExit >> Agreed. Specifically "return" should be equivalent to "exit 0", right? >> And "return -1" (or any other value, including 0) shouldn't be allowed >> in my opinion, raising an exception, in which case the return value >> wouldn't be 0 obviously :) > matz proposed that ignore return argument completely. matz also said to > avoid mistake, return expression with argument (example: "return foo") > should be syntax error. Better yet. >>> - proc { return }.call in toplevel >> If it is the main program, "exit" would be the equivalent. Otherwise, no >> code would be interpreted after the "call" call. >> >> I don't understand what makes this so special. > (1) > pr = proc{return} > def foo(pr) > pr.call # what happen? > end I wonder why someone would write code like this in the first place, but if someone did he is probably expecting the program to terminate with exit if this is the main file. For required files I have no idea what someone would expect from code like this. I'd probably raise an exception in such situation because it is most likely a logic error that could be hard to debug... I know what you mean, should that method "foo" be defined or not? What should be its definition? I have no idea because code like this simply doesn't make any sense to me. > (1') > 1.times{ > return > } This one I can think of. But something like: ['a', 'b'].each {|item| return if defined? item2module(item) } This would simply return from the require. I still don't understand why this would be so special. > (2) > # a.rb > $pr = proc{return} Wow! I wouldn't ever think in something like this! Congratulations, you're really creative! Again, why the hell would someone do something like this? I'd just raise an error when trying to call $pr because return has no more meaning after that file has been already required. > return > end > > matz proposed that "accept return on toplevel (not in block, classes, etc)". I agree, this is way more simple to deal with. Even though I can think about someone using an approach like above, he could also rewrite it like: # ['a', 'b'].each {|item| # return if defined? item2module(item) #} return if ['a', 'b'].any?{|item| defined? item2module(item) } > difficult corner cases. Agreed. > However, matz disagreed the exception approach because of "raise > StopLoading is too long". It is a kind of "name is not good". So it would be just a matter of finding a better name, right? Not that I think it should make any difference because ideally only Ruby internals should see such errors in my opinion. But if he thinks StopLoading is too long (while I find it short) it will be hard to find a shorter meaningful name I guess. Maybe after a good night of sleep, who knows...
on 2012-07-24 04:51
On 2012年07月24日 11:42, Trans wrote: >>> How about redefining `__END__` to allow to call it as a method? >> >> It has compatibility issue that __END__ is related to DATA. > > Then what about `__end__`? > > Tangentially, why not deprecate __END__? Is there some really > important use case that we just can't live without? The whole idea > strikes me as rather hackish, especially considering it is limited to > main file. I'd be much appreciated if __END__ was usable from a library file. I'd write a tiny loader script and place obfuscated script body on __END__ then.
on 2012-07-24 09:52
Issue #4840 has been updated by alexeymuranov (Alexey Muranov). ko1 (Koichi Sasada) wrote: > (2012/07/24 0:44), alexeymuranov (Alexey Muranov) wrote: > > > > How about redefining `__END__` to allow to call it as a method? > > It has compatibility issue that __END__ is related to DATA. > > -- > // SASADA Koichi at atdot dot net Then a keyword `__DATA__` can be added to explicitly mark the beginning of `DATA`, what do you think? Here is a related request: http://www.ruby-forum.com/topic/217535 ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-28381 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2012-07-24 17:06
Issue #4840 has been updated by alexeymuranov (Alexey Muranov).
=begin
I propose the following behavior for `__end__` method when it is used in
a block:
[1, 2].each do |n|
__end__
puts n
end
puts 3
Output:
1
2
So i propose that (({__end__})) does not affect the control flow, and
affect directly the source by saying something like "insert EOF after
the last processed line".
=end
----------------------------------------
Feature #4840: Allow returning from require
https://bugs.ruby-lang.org/issues/4840#change-28398
Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:
I have a situation where there is some code in Gitorious like:
unless defined? GitoriousConfig
# tons of lines here
end
And I would it to look like
return if defined? GitoriousConfig
#tons of lines here
It would be great to allow return from a required file or some other
keyword (break, etc or a new one)
on 2012-07-24 19:52
On Jul 23, 2012, at 7:42 PM, Trans <transfire@gmail.com> wrote: > why not deprecate __END__? Is there some really > important use case that we just can't live without? The whole idea strikes me as rather hackish, especially considering it is limited to main file. I infrequently use __END__ for single-file scripts. It's easier to transport a single file with embedded data than two or more files.
on 2012-07-24 20:16
Em 24-07-2012 12:05, alexeymuranov (Alexey Muranov) escreveu: > puts 3 > > Output: > > 1 > 2 > > So i propose that (({__end__})) does not affect the control flow, and affect directly the source by saying something like "insert EOF after the last processed line". > =end This sounds really weird to me but I'm not against it since I can't see myself writing code like this ever.
on 2012-11-24 05:40
Issue #4840 has been updated by mame (Yusuke Endoh). Target version set to 2.0.0 ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-33784 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: 2.0.0 I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2012-11-24 07:27
Issue #4840 has been updated by mame (Yusuke Endoh). Anyone create a patch conformed to the spec written in [ruby-core:46648]? I guess that my experimental patch ([ruby-core:36811]) is not confirmed completely; perhaps it allows "return from class definition" (but I didn't tested yet). -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-33797 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: 2.0.0 I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2013-02-14 10:59
Issue #4840 has been updated by yhara (Yutaka HARA). Status changed from Assigned to Feedback Assignee changed from matz (Yukihiro Matsumoto) to mame (Yusuke Endoh) Target version changed from 2.0.0 to next minor ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-36277 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Feedback Priority: Normal Assignee: mame (Yusuke Endoh) Category: Target version: next minor I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2013-05-09 04:14
Issue #4840 has been updated by nobu (Nobuyoshi Nakada). File 0001-compile.c-toplevel-return.patch added A simple patch. ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-39213 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Feedback Priority: Normal Assignee: mame (Yusuke Endoh) Category: Target version: next minor I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2013-05-09 14:44
Issue #4840 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas). Pretty simple, indeed :) Not that I understand it, just that I appreciate its simplicity ;) ---------------------------------------- Feature #4840: Allow returning from require https://bugs.ruby-lang.org/issues/4840#change-39220 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Feedback Priority: Normal Assignee: mame (Yusuke Endoh) Category: Target version: next minor I have a situation where there is some code in Gitorious like: unless defined? GitoriousConfig # tons of lines here end And I would it to look like return if defined? GitoriousConfig #tons of lines here It would be great to allow return from a required file or some other keyword (break, etc or a new one)
on 2013-05-09 15:19
On May 9, 2013 12:14 PM, "nobu (Nobuyoshi Nakada)" <nobu@ruby-lang.org> wrote: > > > Issue #4840 has been updated by nobu (Nobuyoshi Nakada). > > File 0001-compile.c-toplevel-return.patch added > > A simple patch. Line 369 has a typo in "rescue"
on 2013-05-09 18:37
Em 09-05-2013 10:19, Matthew Kerwin escreveu: > > Line 369 has a typo in "rescue" > I noticed it, but I thought it was optional to raise in case it hasn't returned previously...
on 2013-05-09 18:40
Em 09-05-2013 13:27, Rodrigo Rosenfeld Rosas escreveu: >> > A simple patch. >> >> Line 369 has a typo in "rescue" >> > > I noticed it, but I thought it was optional to raise in case it hasn't > returned previously... > Sorry, I meant intentional, not optional.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.