in reply to Re^3: Try::Tiny and -E
in thread Try::Tiny and -E

> In hindsight it might be that Try::Tiny is complied before the -E takes effect.

Indeed. In this special case it's actually too early to check from within Try::Tiny.

I checked with feature::feature_enabled("try"); and feature::features_enabled($LEVEL); for various levels.

But the case of perl -E'use Try::Tiny; try {1/0}' could be checked, and from what I see is Try::Tiny not attempting to catch this.

So haarg's reply to the ticket is not fully correct.

On another note: I'm wondering, shouldn't Perl warn if a built-in is clashing with an (exported) sub???

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

EDIT

Ticket updated.

Replies are listed 'Best First'.
Re^5: Try::Tiny and -E
by CountZero (Bishop) on Jan 05, 2026 at 02:21 UTC
    Given the difficulties for a module to test whether one of its routines could clash with a built-in, the solution is easy:
    1. State clearly in the docs that as from Perl 5.40 there may be a clash with a built-in;
    2. Have Try::Tiny check it is running under Perl 5.40 or later and issue a warning about a possible clash.
    And leave it to the programmer to do what is necessary. No need to add unnecessary complexity and fragility to a Tiny::* module.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

      Does it really make sense to make all Try::Tiny-using application start issuing warnings just by upgrading to Perl 5.40?

      I agree that this shouldn't be for Try::Tiny to address (except in documentation).

        I would prefer a warning rather than have the program crash without a proper explanation.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics
      > Have Try::Tiny check it is running under Perl 5.40 or later and issue a warning about a possible clash.

      This:

      • $^V gt v5.40.0

      doesn't make much sense since feature "try" is already available for earlier versions. Furthermore does Perl 5.40 not activate it by default, you still need use v5.40 inside.

      Checking the hinthash of the importing scope for a key feature_try is far more reliable and generates far less false positives.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery