develooper Front page | perl.perl5.porters | Postings from June 2022

Re: Pre-RFC: yield true feature

Thread Previous | Thread Next
From:
Martijn Lievaart
Date:
June 11, 2022 09:27
Subject:
Re: Pre-RFC: yield true feature
Message ID:
5a9994a0-deb6-5a95-8411-99713c515c81@rtij.nl

Op 11-06-2022 om 10:37 schreef Neil Bowers:
> > Can someone show an example, ideally on CPAN, where this gets used?
>
> I _think_ you were asking for an example of someone using the return 
> value from a require. In which case:
>
> https://grep.metacpan.org/search?qci=&q=%3D%20require&qft=&qd=Acme-MetaSyntactic-Themes&f=lib%2FAcme%2FMetaSyntactic%2Funicode.pm 
> <https://grep.metacpan.org/search?qci=&q=%3D%20require&qft=&qd=Acme-MetaSyntactic-Themes&f=lib%2FAcme%2FMetaSyntactic%2Funicode.pm>
>
> This is in BooK’s Acme::MetaSyntactic::unicode module (yeah, Acme):
>
>     if ( $] >= 5.006 && $] < 5.007003  ) {
>         eval { $data = require 'unicode/Name.pl'; };
>     }
>     elsif ( $] >= 5.007003 ) {
>         eval { $data = require 'unicore/Name.pl'; };
>
>         # since v5.11.3, unicore/Name.pl creates subroutines
>         # they end up in our namespace, so get rid of them
>         undef *code_point_to_name_special;
>         undef *name_to_code_point_special;
>     }
>
> Guessing there may be other examples on CPAN – this is just the first 
> one I found with grep.metacpan.org.
>

I'm not sure if that is what Neil ment, because is this really supposed 
to work? The documentation for require says nothing about it returning a 
value. I would say that if this works it is accidental.

I think that Neil ment an example of where not returning a true value 
from a module is used for some decission making (using try/eval) instead 
of aborting compilation.

M4


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