By default, Raku's "die" reports the line number where the "die" is located, what if you'd like the line number of the calling context, ala "carp" with perl 5?
What's the raku analog of perl 5's carp?
FWIW I'm working on a module now. Will post again once I'm done. –
Gilman
There is no direct equivalent to carp
, but you can start raku with the --ll-exception
parameter, which will create a full stack trace on an execution error.
I guess nobody has gotten around to creating a Carp
module yet. Creating a carp
sub shouldn't be too difficult, given that there is a Backtrace
class:
$ raku -e 'say "file: {.file}:{.line}" for Backtrace.new'
file: SETTING::src/core.c/Backtrace.pm6:94
file: SETTING::src/core.c/Backtrace.pm6:94
file: -e:1
There is now a Carp module available on GitHub and should soon be available in the Raku ecosystem. It currently only supports the most basic functionality, but over time it should be improved.
So the answer to your question is to use Carp like you would in Perl 5. :-)
© 2022 - 2024 — McMap. All rights reserved.