3 ms·
It's pretty much exactly like Ingy's XXX perl module from 2006: https://metacpan.org/pod/XXX https://metacpan.org/pod/XXX Prints a YAML dump of "my str", follo
by hoytech 8y ago
It's pretty much exactly like Ingy's XXX perl module from 2006: https://metacpan.org/pod/XXX https://metacpan.org/pod/XXX
Prints a YAML dump of "my str", followed by file/line number information, then returns its argument so it can be embedded in expressions:
$ perl -MXXX -E 'say uc(WWW("my str"))'
--- my str
...
at -e line 1
MY STR
Data::Dump's "ddx" (1996) is also commonly used for print debugging, except it doesn't return the argument.
- kbenson 8y agoAlmost. dbg! also shows the statement in addition to what it evaluates too. That is: dbg!(n * factorial(n - 1)) shows up as: [src/main.rs:5] n * factorial(n - 1) = 2 [src/main.rs:5] n * factorial(n - 1) = 6 [src/main.rs:5] n * factorial(n - 1) = 24 Although, IIRC there was some crazy dumper module by dconway (who else) that worked similar to this, but I don't recall if it returned the value. ... So, I just looked it up, and I found it. Actually, Damien wrote two. One that he updated from 2014 to 2016, and one he started in 2017 and has maintained to the present. I have no idea the reason for that. 1: https://metacpan.org/pod/Data::Show https://metacpan.org/pod/Data::Show 2: https://metacpan.org/pod/Data::Dx https://metacpan.org/pod/Data::Dx
- hoytech 8y agoHehe nice ones, thanks for the links! :) Yep leave it Damien. I remember he did something similar for a test module where it would show the expressions that were evaluated in the test failure output.