Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Fun with Prototypes

by LanX (Saint)
on Jul 19, 2017 at 21:45 UTC ( [id://1195529]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1195529]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-28 21:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found