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:40
Subject:
Re: Allowing require to return false
Message ID:
CANgJU+VPY6+ypb9USGrQkvYUYpMC+uPKoyu9RKnZ0+Wv3s1MJA@mail.gmail.com
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.

cheers,
Yves

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