[#88925] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
4 messages
2018/09/09
[#88927] Re: [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical
— Eric Wong <normalperson@...>
2018/09/09
ko1@atdot.net wrote:
[#88926] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
3 messages
2018/09/09
[#89218] [Ruby trunk Bug#15130] open-uri hangs on cygwin — duerst@...
Issue #15130 has been updated by duerst (Martin D端rst).
5 messages
2018/09/30
[ruby-core:88913] [Ruby trunk Feature#14927] Loading multiple files at once
From:
nobu@...
Date:
2018-09-09 04:33:33 UTC
List:
ruby-core #88913
Issue #14927 has been updated by nobu (Nobuyoshi Nakada).
shevegen (Robert A. Heiler) wrote:
> In the event that the project may be relocated, here is the
> copy/paste outcome of that code:
>
> require "fpm/namespace"
>
> require "fpm/package"
> require "fpm/package/dir"
> require "fpm/package/gem"
> require "fpm/package/deb"
> require "fpm/package/npm"
> require "fpm/package/rpm"
> require "fpm/package/tar"
> require "fpm/package/cpan"
> require "fpm/package/pear"
> require "fpm/package/empty"
> require "fpm/package/puppet"
> require "fpm/package/python"
> require "fpm/package/osxpkg"
> require "fpm/package/solaris"
> require "fpm/package/p5p"
> require "fpm/package/pkgin"
> require "fpm/package/freebsd"
> require "fpm/package/apk"
Doesn't the order matter?
----------------------------------------
Feature #14927: Loading multiple files at once
https://bugs.ruby-lang.org/issues/14927#change-73950
* Author: deneb (S辿bastien Durand)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Just a proof concept I wanted to share. Maybe it could be useful?
Say you want to load all the .rb files in your lib directory:
~~~ ruby
Dir['lib/**/*.rb'].each { |file| load(file) }
~~~
This approach may not work if your files have dependencies like that:
~~~ ruby
# lib/foo.rb
class Foo < Bar
end
~~~
~~~ ruby
# lib/bar.rb
class Bar
end
~~~
Foo class needs Bar class. You will get a NameError (uninitialized constant Bar).
So in my personal projects, I use this algorithm to load all my files and to automatically take care of dependencies (class/include):
~~~ ruby
def boot(files)
i = 0
while i < files.length
begin
load(files[i])
rescue NameError
i += 1
else
while i > 0
files.push(files.shift)
i -= 1
end
files.shift
end
end
end
~~~
~~~ ruby
boot Dir['lib/**/*.rb'] # It works! foo.rb and bar.rb are properly loaded.
~~~
My point is: it would be cool if Kernel#load could receive an array of filenames (to load all these files in the proper order). So we could load all our libs with just a single line:
~~~ ruby
load Dir['{path1,path2}/**/*.rb']
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>