in reply to Re^4: Try::Tiny and -E
in thread Try::Tiny and -E
> It doesn't matter when the Try::Tiny is compiled.
I've explicitly tested this with feature::feature_enabled() and order definitely matters.
It's basically the difference between:
use feature "try"; use Try::Tiny;
vs
use Try::Tiny; # no chance (well see footnote°) use feature "try";
And that's because lexical scope starts right at the point of declaration.
> it's out of reach of Try::Tiny since I believe it's intentionally a pure-Perl module.
It's very much possible with a pure-Perl module like I said. The _enabled routines in feature are basically checking the hinthash %^H returned by caller for the needed level.
And the hint-key is called "feature_try"
A slight complication is that feature introduced "try" before it provided the *_enabled checks. IOW one needs to copy the hint-hash lookup logic for older Perl versions.
°) the wrong order could be fixed by using an INIT {} block doing the check after all compilations are completed, but I question the wisdom of such a fragile construct. Too many edge cases.¹
¹) Turns out that neither INIT,CHECK or UNITCHECK can see the hint anymore.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
little demo v5.38
perl -E'BEGIN{say join "\n",feature::features_enabled()}' bareword_filehandles bitwise current_sub evalbytes fc indirect isa module_true multidimensional postderef_qq say signatures state unicode_eval unicode_strings
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Try::Tiny and -E
by ikegami (Patriarch) on Dec 29, 2025 at 07:28 UTC | |
by LanX (Saint) on Dec 29, 2025 at 12:05 UTC | |
by ikegami (Patriarch) on Dec 30, 2025 at 00:04 UTC | |
by LanX (Saint) on Dec 30, 2025 at 03:17 UTC | |
by ikegami (Patriarch) on Dec 30, 2025 at 05:01 UTC | |
| |
|
Re^6: Try::Tiny and -E
by ikegami (Patriarch) on Dec 29, 2025 at 07:01 UTC | |
by LanX (Saint) on Dec 29, 2025 at 11:56 UTC | |
by ikegami (Patriarch) on Dec 30, 2025 at 00:02 UTC | |
by LanX (Saint) on Dec 30, 2025 at 03:10 UTC | |
by ikegami (Patriarch) on Dec 30, 2025 at 05:06 UTC |