[Bioperl-l] Bio::Root::IO _readline/_pushback behavior

Kai Blin kai.blin at biotech.uni-tuebingen.de
Wed Aug 3 04:55:04 EDT 2011


-----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 case
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 what
other pieces of the code did. Currently, this is not the case, because
the readbuffer that _pushback pushes back into has new strings appended
to the end but readline removes them from the front.

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, changing
the _pushback function to "unshift" instead of "push" to the readbuffer
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 without
this patch.

Any comments from the core devs?

Cheers,
Kai

- -- 
Dipl.-Inform. Kai Blin         kai.blin at biotech.uni-tuebingen.de
Institute for Microbiology and Infection Medicine
Division of Microbiology/Biotechnology
Eberhard-Karls-Universität Tübingen
Auf der Morgenstelle 28                 Phone : ++49 7071 29-78841
D-72076 Tübingen                        Fax :   ++49 7071 29-5979
Germany
Homepage: http://www.mikrobio.uni-tuebingen.de/ag_wohlleben
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOOQzoAAoJEKM5lwBiwTTPO6QIAMDN1bAm1FFD98F0rhN7TCpW
sV2sLkQDESK9YjCxp3kAqCpg7ZCArcA5l7HmEdAZFTzdFnsfnvKJmNB86C30QXJs
6XcYSbvBIPQdhjK7WIhG2pANItiTxKTGgXDZklVjgj2dVT4kSkCgdGYAAMssT1hn
n1/jkBJu5uuCq43Wv5Ia+wEhdN0M+xgKc9x7MF/ikO2qr6x24odMNTW8VgyLsYie
p9M68U23aStip2rxV1hrhZzbnjLz66V6O9fIEHmm5CYLfcGXkcrclzLIeptepSj1
bj/7dWIdXy8VnoSNx4RbckHSkMbdIkmyPKzmoYFN7p3FvmrSXsOmB6nfD0hEkbY=
=S5ff
-----END PGP SIGNATURE-----


More information about the Bioperl-l mailing list