in reply to Fun with Prototypes

More fun for you: ;)

Some people want debug functions to disappear without footprint in production.

Like with Smart::Comments but without source filter.

Try to find a way where changing the prototype of a function &dmp will turn the call to a no op.

Your bar /#(\w+)/, @a; is already quite close, but it's still involving a division. :)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Fun with Prototypes
by tobyink (Canon) on Jul 22, 2017 at 11:22 UTC

    Isn't this sufficiently clear?

    use constant DEBUG => 0; use Data::Dumper; # ... warn Dumper($myvar) if DEBUG;

    Or PerX::Assert.

      > Isn't this sufficiently clear?

      > ...

      > warn Dumper($myvar) if DEBUG;

      clear but unnecessarily verbose.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Re^2: Fun with Prototypes
by LanX (Saint) on Jul 20, 2017 at 12:49 UTC
    an example avoiding a sub-call, unfortunately the division in void context is not optimized away.

    and the warning will create runtime overhead, too :/

    update
    But I think a little overhead is acceptable when debugging.

    another edge case are empty arrays causing a division by zero...

    update:

    fixed minor bug

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!