Michael T. Richter
8/31/2007 2:18:00 PM
On Fri, 2007-31-08 at 22:48 +0900, Florian Aßmann wrote:
> Hi Michael,
>
> 1. DATA *constant* becomes defined:
> DATA.inspect # => "This is the data in test1.rb."
> > require 'test2'
> *snip*
> 2. test2 becomes loaded
> 3. test2 reads lines from DATA(0) to DATA(EOF) and puts them
> >> puts "test2.rb = " + DATA.readlines.to_s
>
> test2.rb = This is the data in test1.rb.
>
> >> # ignored unless it's called first
> >> __END__
> >> This is the data in test2.rb.
> *snip*
> 4. test1 reads lines from DATA(EOF) to DATA(EOF) and puts them
> > puts "test1.rb = " + DATA.readlines.to_s
>
> test1.rb =
>
> > __END__
> > This is the data in test1.rb.
>
> Your dealing with a constant here, you should expect that it won't change Ok,
> you maybe expected that the require behaves like the ruby-bin...
OK, that makes a twisted sort of sense, but... I *REALLY* do not like
this. At all. Not just because it royally screws what I'm working on
(although I may have a slightly clumsier workaround) but also because it
means any libraries I require in my code can suck up my __END__ data. I
would have expected the DATA constant to be localized in some way to the
language unit it's being used in, not passed around freely like some
kind of depraved party girl.
And what's the "ruby-bin"?
--
Michael T. Richter <ttmrichter@gmail.com> (GoogleTalk:
ttmrichter@gmail.com)
All really first class designers are both artists, engineers, and men of
a powerful and intolerant temper, quick to resist the least modification
of the plans, energetic in fighting the least infringement upon what
they regard as their own sphere of action. (Nevil Shute)