Feature #1591
closedDATA handle unusable in required modules
Description
=begin
I have a Module defined in a file that gets required by a script. Inside the module I set a class variable:
module MyModule
class MyClass
@@data = DATA.readlines
def MyClass.getData
return @@data
end
# ...
end
end
END
lots
of
words
...
DATA is undefined! If I add an END section to the script that requires my module, DATA becomes defined and it contains the data in the script. Obviously the way this works makes DATA + END useless except for the one case where a person wants to access END data from within their own script. I would think the more common case would be a module requires a bunch of data and it is convenient to just put that at the end of the file that contains the module and load it up when it gets required.
=end
Updated by nobu (Nobuyoshi Nakada) almost 15 years ago
- Category set to core
- Assignee set to matz (Yukihiro Matsumoto)
- Target version set to 3.0
=begin
=end
Updated by shyouhei (Shyouhei Urabe) over 13 years ago
- Status changed from Open to Assigned
=begin
=end
Updated by naruse (Yui NARUSE) over 12 years ago
- Project changed from Ruby master to 14
- Category deleted (
core) - Target version deleted (
3.0)
Updated by naruse (Yui NARUSE) over 12 years ago
- Project changed from 14 to Ruby master
Updated by mame (Yusuke Endoh) about 12 years ago
- Status changed from Assigned to Rejected
I'm rejecting this feature ticket because no progress has been
made for a long time. See [ruby-core:42391].
This feature is difficult to implement in terms of resource of
file descriptor. The interpreter must keep the descriptor of
each source file that ends with END because the content may
be accessed. This leads to a shortage of file descriptor.
AFAIK, DATA and END came from Perl. The behavior of Ruby
is also the same as Perl's.
--
Yusuke Endoh mame@tsg.ne.jp