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

Re: Allowing require to return false

Thread Previous | Thread Next
From:
demerphq
Date:
July 27, 2018 19:52
Subject:
Re: Allowing require to return false
Message ID:
CANgJU+UwP8Udj_Jpvrk3-LKegLR8L=yBmjh6JcDZsNLRkh3U2A@mail.gmail.com
On Fri, 27 Jul 2018 at 21:40, demerphq <demerphq@gmail.com> wrote:
>
> On Fri, 27 Jul 2018 at 21:12, David Nicol <davidnicol@gmail.com> wrote:
> >
> >
> > is this subtle difference checked in the test suite?
>
> No idea. I would assume so, but...
>
> > As perldoc -f require doesn't describe this subtle difference, and actually documents a semantic inconsistent with it, with
> >
> >
> > if (exists $INC{$filename}) {
> > return 1 if $INC{$filename};
> > croak "Compilation failed in require";
> > }
>
> I think your quote removes a valuable context, the very next clause is:
>
>                      elsif (!$result) {
>                           delete $INC{$filename};
>                           die "$filename did not return true value";
>                       }
>
> which shows the case I mean.
>
> The pattern is:
>
> if we have no entry in INC for package
> find the file
> set INC
> do the file
> if we die, overwrite the INC entry with undef
> if we retiurn false, remove the INC entry
> if we return true, leave the INC entry
>
> >
> > and
> >
> > Note that the file will not be included twice under the same specified name.
>
> Yes, that is wrong.  If require returns false it can be included again.
>
> >
> > it seems like a documentation patch would be eminently committable.
>
> Yeah, i guess so. Assuming this is deliberate. I always assumed it was
> deliberate.

Although thinking about it more it is weird as hell. You can install
code into the process, but not have any sign of it in %INC. And later
code could use that code anyway. Hrm....

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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