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

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

Thread Previous
From:
Brian Fraser
Date:
October 23, 2011 17:20
Subject:
Re: [PATCH] Fix PerlIO::via's GETARG method
Message ID:
CA+nL+nbysv2W6LhxwEcGpt5cw3sktn2WfJTcrSGhHV6x+n=khw@mail.gmail.com
On Sun, Oct 23, 2011 at 6:48 PM, Father Chrysostomos <sprout@cpan.org>wrote:

> 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.


I thought about this, but I didn't know how much of Encode, or things like
PerlIO::Utils, would need changing -- Getting PerlIO::via up to the current
spec was the path of least resistance.


>  (And we need to look into making COW the default.)
>
>
This I wouldn't know about, apologies.


> >
> > 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::*?
>
>
The PerlIO::via internals assume so -- My kneejerk reaction would be to say
probably not, here be bugs, but it's consistent with what's already there.


> >
> > 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?
>
>
PerlIIIIIOOOOO...!! :)


> Could you send future patches to perlbug, so they are less likely to get
> lost?
>
>
Will do, sorry for the trouble.


Thread Previous


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