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

Re: The coderef in @INC strikes back

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
August 22, 2001 13:35
Subject:
Re: The coderef in @INC strikes back
Message ID:
20010822223806.A696@rafael
On 2001.08.22 11:46 Nicholas Clark wrote:
> 
> Around Feb this year (I think) a patch from me was added so that if the
> "coderef" is actually a blessed reference then its INC method is called.
> I believe that in doing this I've actually bust a specific corner case of
> a blessed array reference (code in pp_ctl.c currently seems to dereference it
> to get 1st element and then do the "is it coderef or blessed?" check - this
> means that you can't use the INC method on an object that is a blessed
> hashref. This is probably wrong)

The Foo::INC method trick seems to work very well (see my reply to
J. Stowe). Just remember that INC should always be fully qualified.

> The core filter is subtly broken in its implementation - see the message I
> reference for 1 case. At the time that Ken Fox provided the original patch
> Filter::* had not been assimilated. My opinion is that the core filter should
> be removed, and the pp_ctl.c code be rewritten to use Filter::Simple.
> However, I don't know (yet) how to implement the necessary perl opcodes
> to do this.

Do we need the ability to include source code filters via hooks in @INC ?
This is an undocumented feature, so backward compatibility is not very
important here. My suggestion would be to drop this, and to say that the
subroutines executed via @INC are called in scalar context, and should return
undef or a filehandle.

> > Anyway, documentation and tests are needed here. Also, I think that
> > the core modules that iterate over @INC, assuming that it contains
> > strings, should be reviewed.
> 
> A reasonable idea. Who gets to do this? :-)

Well, I'm slowly working on docs and tests. But I'm not fluent with PP
code.

About the docs, here the layout I've in mind (as suggested by Jarkko) :
- a very small overview in perlvar/@INC
- full explanation in perlfunc/require

Where should the tests go ? I thought about making a new test file in t/op.

Thread Previous | 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