in reply to [Perl 6]: Small discoveries VI, die

G'day holli,

This interested me because it seemed to be (sort of) the opposite of what a newline does with Perl5's die. Adding a newline to the message stops additional information such as line number and code source (not actually a stack trace):

$ perl -e 'die "with info"' with info at -e line 1. $ perl -e 'die "without info\n"' without info $

However, when I tried that with Perl6, it printed the message (with a newline where added) and the same information regardless of whether a newline had been used:

$ perl6 -e 'die "with info"' with info in block <unit> at -e line 1 $ perl6 -e 'die "without info\n"' without info in block <unit> at -e line 1 $

Putting the die in a sub, didn't change the Perl5 output:

$ perl -e 'sub dead { die "with info" } dead()' with info at -e line 1. $ perl -e 'sub dead { die "without info\n" } dead()' without info $

But, with Perl6, it gave the same information as before, plus info on the sub calling the die, with and without a newline:

$ perl6 -e 'sub dead { die "with info" }; dead()' with info in sub dead at -e line 1 in block <unit> at -e line 1 $ perl6 -e 'sub dead { die "without info\n" }; dead()' without info in sub dead at -e line 1 in block <unit> at -e line 1 $

I tried a further level of calling. The Perl5 output was unchanged. The Perl6 output added the extra level to the stack trace but was otherwise unchanged.

$ perl -e 'sub drop { dead() } sub dead { die "with info" } drop()' with info at -e line 1. $ perl -e 'sub drop { dead() } sub dead { die "without info\n" } drop( +)' without info $ perl6 -e 'sub drop { dead() }; sub dead { die "with info" }; drop()' with info in sub dead at -e line 1 in sub drop at -e line 1 in block <unit> at -e line 1 $ perl6 -e 'sub drop { dead() }; sub dead { die "without info\n" }; dr +op()' without info in sub dead at -e line 1 in sub drop at -e line 1 in block <unit> at -e line 1 $

I've tinkered with Perl6 every few years or so, just to see progress, but I'm very much a novice. Please provide some example code and output demonstrating what you're describing; it's entirely possible I've missed the point.

Assuming the version number refers to a date (YYYY.MM), it looks like my copy of Perl6 is about 18 months old: perhaps the behaviour you describe is new.

$ perl6 -v This is Rakudo version 2016.04 built on MoarVM version 2016.04 implementing Perl 6.c.

I'm pretty sure the Perl5 behaviour has always been the same (such as I've shown); I certainly recall using it in v5.6. Just for completeness, my current version:

$ perl -v | head -2 | tail -1 This is perl 5, version 26, subversion 0 (v5.26.0) built for darwin-th +read-multi-2level

Update (cosmetic): I removed instances of "ken@ganymede: ~/tmp", which are part of my complete prompt, unrelated to anything I posted, and really just noise. I normally take these out before posting; a few had slipped through this time.

— Ken

Replies are listed 'Best First'.
Re^2: [Perl 6]: Small discoveries VI, die
by Laurent_R (Canon) on Oct 22, 2017 at 11:05 UTC
    Hi kcott,
    Assuming the version number refers to a date (YYYY.MM), it looks like my copy of Perl6 is about 18 months old: perhaps the behaviour you describe is new.
    Yes, the version number refers to the date (year and month).

    With the latest available version of Rakudo Star / Perl 6:

    This is Rakudo version 2017.07 built on MoarVM version 2017.07 implementing Perl 6.c.
    I obtain exactly the same results as yours, with the presence or absence of a new line apparently making no difference to the output; and with the subroutine call stack in the output when die is called from a subroutine.

    I may also have missed holli's point, but I can't see a difference.

    And the documentation (https://docs.perl6.org/routine/die) says nothing on that.

      However, when I tried that with Perl6, it printed the message (with a newline where added) and the same information regardless of whether a newline had been used:
      That *is* the point. Wether or not you put a newline at the end of the argument to die, it will print a stack trace. Unlike Perl 5.


      holli

      You can lead your users to water, but alas, you cannot drown them.
        OK, thank you holli, then we agree. I guess Ken and myself misunderstood your point.

      G'day Laurent_R,

      "Yes, the version number refers to the date (year and month)."

      Thanks for the confirmation of the version number format and additional information.

      "I obtain exactly the same results as yours, ..."

      Thanks for taking the time to check that. With holli's clarification of the OP text, I'd say that issue's now resolved.

      — Ken