[Bioperl-l] Bio::Root::IO _readline/_pushback behavior
hlapp at drycafe.net
Thu Aug 4 17:31:52 EDT 2011
I agree. In fact I'm surprised that $io->_pushback() does not act like
unshift() - that's I thought how it is used.
On Aug 3, 2011, at 10:16 AM, Chris Fields wrote:
> On Aug 3, 2011, at 3:55 AM, Kai Blin wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>> Hi folks,
>> as I mentioned on https://redmine.open-bio.org/issues/3264 there is
>> something odd going on with Bio::Root::IO's _readline/_pushback
>> functions. This seems to be intentional, at least there is a test
>> asserting the behaviour I'm seeing. It his however very confusing
>> to the
>> unexpecting programmer using the code.
>> One assumption I'd immediately make would be that if I have code that
>> does a $foo = $io->_readline; $io->_pushback($foo); $bar =
>> $io->_readline;, $foo will be the same string as $bar, regardless
>> other pieces of the code did. Currently, this is not the case,
>> the readbuffer that _pushback pushes back into has new strings
>> to the end but readline removes them from the front.
> I think this test is performed in the regressions already, but if
> not then it is more than welcome.
>> This easily violates the "principle of least surprise", so I think we
>> should change the readbuffer to a stack. As far as I can tell,
>> the _pushback function to "unshift" instead of "push" to the
>> breaks only the Root/RootIO.t test designed to test the old
>> behaviour. I
>> don't see any other tests failing on my system that don't fail
>> this patch.
>> Any comments from the core devs?
> I don't have a problem with that beyond the change to the RootIO.t
> tests (it implies a specific behavior that some developers expect,
> so is a very subtle API change). However, this is how one would
> expect it, to be more like an 'unread' stack instead of a queue. In
> fact, there is a module I used for Biome's pushback/readline called
> IO::Unread that implements an IO layer for mimicing this behavior,
> might be worth looking into.
> Christopher Fields
> Senior Research Scientist
> National Center for Supercomputing Applications
> Institute for Genomic Biology
> University of Illinois Urbana-Champaign
> 1206 W. Gregory Dr. , MC-195
> Urbana, IL 61801
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
: Hilmar Lapp -:- Durham, NC -:- hlapp at drycafe dot net :
More information about the Bioperl-l