Re: Proposed feature: die on compile with undefined functions
[email protected] (demerphq)
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <CANgJU+V7fOrgB9JwqsSgmOQfbP2vNVD=fTA7FS-b3HO5hT5SWA@mail.gmail.com> |
On Thu, 29 Jan 2026, 11:52 Philippe Bruhat (BooK), <[email protected]> wrote: > 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 > Indeed, "halting problem" hard. 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 And while a super strict mode could require forward declarations for this exact case there are others where we document that forward references to fully qualified subs should work. Yves