[ruby-core:71413] [Ruby trunk - Feature #4840] Allow returning from require

From: rr.rosas@...
Date: 2015-11-09 10:54:51 UTC
List: ruby-core #71413
Issue #4840 has been updated by Rodrigo Rosenfeld Rosas.


Thanks for the update, but I'd like to point out the description in that do=
cument is not accurate:

~~~
### Before
unless cond
  class C
  end
end
# =E2=80=A6 or =E2=80=A6
class C
end unless cond
~~~

This is like the actual code looks like (the one that motivated this featur=
e request):

https://github.com/grjones/gitorious-submodule-dependencies/blob/master/con=
fig/initializers/gitorious_config.rb

~~~
unless defined? GitoriousConfig
  GitoriousConfig =3D c =3D YAML::load_file(File.join(Rails.root,"config/gi=
torious.yml"))[RAILS_ENV]

  # make the default be publicly open
  GitoriousConfig["public_mode"] =3D true if GitoriousConfig["public_mode"]=
.nil?

  # ...
~~~

As you can see, the assumption that we would be dealing with a conditional =
single class declaration is false, so, the alternative proposal for current=
ly handling this situation does not really apply in several cases.

----------------------------------------
Feature #4840: Allow returning from require
https://bugs.ruby-lang.org/issues/4840#change-54782

* Author: Rodrigo Rosenfeld Rosas
* Status: Feedback
* Priority: Normal
* Assignee: Nobuyoshi Nakada
----------------------------------------
I have a situation where there is some code in Gitorious like:

~~~ruby
unless defined? GitoriousConfig
  # tons of lines here
end
~~~

And I would it to look like

~~~ruby
return if defined? GitoriousConfig

#tons of lines here
~~~

It would be great to allow return from a required file or some other keywor=
d (break, etc or a new one)

---Files--------------------------------
feature-4840.odp (114 KB)
0001-compile.c-toplevel-return.patch (1.71 KB)


--=20
https://bugs.ruby-lang.org/

In This Thread