Re: Proposed feature: die on compile with undefined functions
[email protected] ("Philippe Bruhat (BooK)")
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Jan 28, 2026 at 11:59:47AM -0600, David Condon wrote:
>
> *1. Here is a problem*
> Scripts that have undeclared subroutines will run, even though the
> subroutines are not declared/loaded/whatever:
>
> There are no syntax changes. The only change is that undefined subroutines
> would be treated the same way that undefined scalars are treated.
s/undefined scalares/undeclared scalars/
> I want perl to check for the undefined function max before running the
> script, similarly to the way that this 1-line script:
> *4. Here are potential problems*
>
> I am unaware of any. I just want something that will happen anyway to
> happen sooner to save time. This change *shouldn't *be buggy.
The problem is see is that it's extremely hard to detect if a function
will be defined by the time Perl tries to call it:
use v5.42;
require List::Util;
List::Util->import("max");
say max( 1..10, -1..7);
All of those lines happens at run time, and max is available by the time
it's called. At the end of compilation, though, max is not defined.
--
Philippe Bruhat (BooK)
You can always buy another house but you cannot put a price on a home.
(Moral from Groo The Wanderer #63 (Epic))