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