develooper Front page | perl.perl5.porters | Postings from October 2011

[PATCH] Fix PerlIO::via's GETARG method

Thread Next
From:
Father Chrysostomos
Date:
October 23, 2011 13:49
Subject:
[PATCH] Fix PerlIO::via's GETARG method
Message ID:
54D0C918-F68D-49F7-BBA5-38E47EE7EC5C@cpan.org
I don’t really understand this, so my comments may be wrong.

Brian Fraser wrote:
> First patch makes this:
> 
> use PerlIO::via::QuotedPrint;
> sub PerlIO::via::QuotedPrint::GETARG { "QuotedPrint" }
> open my $fh, "<:via(QuotedPrint)", undef or die $!;
> print PerlIO::get_layers($fh);
> 
> Stop throwing "Attempt to free" warnings by creating a fresh scalar; This is
> required because of this comment in perlio.c's PerlIO_get_layers:
> /* There is some collusion in the implementation of
> XS_PerlIO_get_layers - it knows that name and flags are
> generated as fresh SVs here, and takes advantage of that to
> "copy" them by taking a reference. If it changes here, it needs
> to change there too. */

It sounds to me as though XS_PerlIO_get_layers should be fixed.  (And we need to look into making COW the default.)

> 
> The second patch makes
> 
> use PerlIO::via::QuotedPrint;
> open my $fh, "<:via(QuotedPrint)", undef or die $!;
> print PerlIO::get_layers($fh);
> 
> Return "via(QuotedPrint)" instead of an argless "via"; It also stop an
> assertion from failing if those are enabled, as before it would return NULL
> instead of an SV.

Is it safe to assume any stash name longer than 13 is PerlIO::via::*?

> 
> Is GETARG worth documenting? Using it before this patch was broken, and
> using it after is mostly superfluous. Seems like the kind of implementation
> detail to hide under the rug.

Nothing on CPAN is using it.  But if I understand it correctly it does seem like a nice feature.

> 
> Also, surprisingly (to me), redefining GETARG after an open does not affect
> the name returned by the already-existing filehandle:
> 
> perl -MPerlIO::via::QuotedPrint -E ' *PerlIO::via::QuotedPrint::GETARG = sub
> { "Eeyup" }; open my $fh, "<:via(QuotedPrint)", undef or die $!; say
> PerlIO::get_layers($fh); *PerlIO::via::QuotedPrint::GETARG = sub { "Uunope"
> }; say PerlIO::get_layers($fh);'
> 
> I'm guessing that's intended behavior?

Who knows?

Could you send future patches to perlbug, so they are less likely to get lost?


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About