1parrota (>):
> 1. Should there be a way to make "die" behave like the Perl 5 version,
> reporting the place of death unless the message is terminated by \n ?
> The \n no longer suppresses the location indormation. I can't find a
> definition either way in the Synopses.

Yes, there should.

The problem is one of the perfect being the enemy of the good. People
pretty much agree that the mechanism shouldn't be governed by "\n" at
the end of the error string, but no-one has suggested anything
significantly more attractive either. So here we are, currently
without a way to get "die" (and "warn") without location information.

> 2. The following code (c_to_f) is broken: (I subsequently found the
> correct way to loop over the 0..20 values)
>
> #! /home/guru/bin/perl6
> my $c;
>
> for $c = 0..20 {
>    say $c;
>    my  $f = ($c * 9 / 5) +32;
>    say $f;
> }
>
> It produces the following result:
>
> $ ./c_to_f
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> 69.8
>
> "Say" is clearly treating $c as an array in some way, but the arithmetic
> is using a value of 21 (the number of array elements) in $c. Is there a
> reasonable explanation for what's happening?

Yes.

$c contains a Range object, namely C<0..20>. The Range object
stringifies to what you see by the output of C<say>.

<masak> rakudo: my $c = 0..20; say ~$c
<p6eval> rakudo f34aa8: OUTPUT«0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20␤»

When you use it in a math formula, it numifies to the number of
integer "elements" in the range.

<masak> rakudo: my $c = 0..20; say +$c
<p6eval> rakudo f34aa8: OUTPUT«21␤»

The basic misunderstanding in your code seems to be that '$c = 0..20'
will do anything other than assign a range to C<$c>. What you wanted
was probably 'for 0..20 -> $c { ... }'.

> 3. The following is an edited transcript of a session playing with ...
> (the comment lines inserted afterwards). Are they the intended results?
>
> $ perl6 -e 'say "Yo"; {...} ; say "Bye" '
> Yo
> #       Unannounced demise

Should quit with a message. Known bug.

> $ perl6 -e 'say "Yo"; {???} ; say "Bye" '
> Yo
> Stub code executed  in <anon> at line 1
> Null PMC access in setprop()
>  in main program body at line 1
> #       Is this message correct?

The "Stub code" message is correct. It certainly shouldn't Null PMC
access. Known bug.

> $ perl6 -e 'say "Yo"; if !{...}  { say "Bye"} '
> Yo
> $ perl6 -e 'say "Yo"; if {...}  { say "Bye"} '
> Yo
> Bye
> #       The opposite to what I'd expect, if ... returns failure

Same base cause as your first example above. Similarly wrong.

> $ perl6 -e 'say "Yo"; say {...} '
> Yo
> _block1063
> #       What is that? The reference to an anonymous subroutine?

Yes, and correct, if ugly. You're asking Perl 6 to print the block C<{...}>.

HTH,
// Carl

Reply via email to