Why a StringIO object instead of a File object? (Cf. last night's discussion on #ruby-lang :-)
David Black
Most operating systems have a limit on the number of filehandles that can be open at any given time, or can restrict it on a per-user basis. If these filehandles are consumed by extensive use of unclosed DATA sections, that limit could be reached quickly. The likelihood of this is increased because I don't think that most people will be used to doing DATA.close.
I'm not opposed to EndData returning filehandles, but I don't think that most of the data will be large enough to warrant the use of a filehandle for each one, because much of the data would be already loaded.
I think a StringIO solution is the simplest one, but an alternate solution would be delegate to a File that opens the file the first time it is used.
-- Paul Brannan
I second that. DATA sections could be really large and thus they should not be kept in memory. IMHO when accessing the data it could be a normal filehandle that overrides the seek operations in order to prevent setting the current position to something before the section tag.
-- Robert Klemme
The data is in memory to some degree already, as Ruby has to have the file in memory at least temporarily.
-- Austin Ziegler
Whether it is useful or not, though I personally stand with pro-use, if DATA section is already available, it is reasonable that it should be specific for each file. I madly love ruby's PLOS, however, at this time if I call DATA.read in required script, then main($0)'s DATA section is read. It is somewhat surprising.
Above comment is written by me.
-- Gyoung-Yoon Noh
Why a StringIO object instead of a File object? (Cf. last night's discussion on #ruby-lang :-)
David Black
Most operating systems have a limit on the number of filehandles that can be open at any given time, or can restrict it on a per-user basis. If these filehandles are consumed by extensive use of unclosed DATA sections, that limit could be reached quickly. The likelihood of this is increased because I don't think that most people will be used to doing DATA.close.
I'm not opposed to EndData returning filehandles, but I don't think that most of the data will be large enough to warrant the use of a filehandle for each one, because much of the data would be already loaded.
I think a StringIO solution is the simplest one, but an alternate solution would be delegate to a File that opens the file the first time it is used.
-- Paul Brannan
I second that. DATA sections could be really large and thus they should not be kept in memory. IMHO when accessing the data it could be a normal filehandle that overrides the seek operations in order to prevent setting the current position to something before the section tag.
-- Robert Klemme
The data is in memory to some degree already, as Ruby has to have the file in memory at least temporarily.
-- Austin Ziegler
Whether it is useful or not, though I personally stand with pro-use, if DATA section is already available, it is reasonable that it should be specific for each file. I madly love ruby's PLOS, however, at this time if I call DATA.read in required script, then main($0)'s DATA section is read. It is somewhat surprising.
Above comment is written by me.
-- Gyoung-Yoon Noh