develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [ID 20010703.002] [5.6.2-to-be] PerlIO is EVIL

Thread Previous
Jarkko Hietaniemi
July 3, 2001 05:51
Re: [ID 20010703.002] [5.6.2-to-be] PerlIO is EVIL
Message ID:
> Tracing through perlio.c shows how much EVIL it is.  All 80K of it.  I 
> simply have no words for this code.  Extremely inefficient and bloated,
> doing enormous amount of work for trivial tasks - not even mentioning
> how buggy it turns out to be!   Apparently the principal task is to have
> CRNL translation, and the principal usage is on Dosish systems - which
> *already* do this with binary().
> In the example of Term::ReadKey, CRTL *knows* that TTYs should be opened
> in the binary mode.  PerlIO does not.  There are miriads of such special
> cases.
> This code *duplicates* the work already done in the CRTL, thus lead to
> double translations (as easy examples show).  Not even mentioning that
> this code is probably 1/10 as efficient as the code in CRTL (and 5 times
> bulkier and sub-call-deeper) - in*****tent is the only word I could find
> for perlio.c.
> The task of CRNL translation is very quick and easy - with a proper
> implementation.  No need to extra copying, no nothing: just keep an extra
> pointer into the buffer.  Whatever is before the pointer is translated,
> whatever is after is not - and the char immediately after the pointer
> should be ignored.  On _fill() move the pointer to "\n" in the nearest
> "\r\n" pair, and replace the first "\r" by "\n".  That's all.  ungetc()
> modifies only the already-translated part, there is no need to untranslate
> things (which is impossible anyway).  Similar things may be done for all
> the other needed translations.
> [It is also very efficient to report only the part until this buffer as
> available, if it is available.  This allows simple inlining of getc().]
> I do not even want to mention that in many cases all Perl needs is a
> pointer to the buffer, but PerlIO insists on copying the stuff...
> I do not think that PerlIO is ready for 5.6.2.

Ilya, the PerlIO subsystem has been in open and public development for
more than eight months now.  It's too bad you weren't there to find
out and fix bugs since the shape PerlIO is in now is the shape it's
going out in 5.7.2 (not 5.6.2, mind, 5.6.2 will probably wait well
after 5.8.1) AND 5.8.0.

$jhi++; #
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About