develooper Front page | perl.perl6.users | Postings from January 2021

Strange behaviour in REPL

Thread Next
From:
Richard Hainsworth
Date:
January 11, 2021 17:36
Subject:
Strange behaviour in REPL
Message ID:
f75dc223-0cc1-047c-cec5-17df7cbbdb69@gmail.com
I want to test for a key being defined in one hash, and if it is, then 
it should be a hash, and I need the value of that second key.

So I was testing my syntax with raku and got the following:

raku
Welcome to ๐‘๐š๐ค๐ฎ๐๐จโ„ข v2020.12.
Implementing the ๐‘๐š๐ค๐ฎโ„ข programming language v6.d.
Built on MoarVM version 2020.12.

To exit type 'exit' or '^D'
 > my %h = <one two three> Z=> 1..*
{one => 1, three => 3, two => 2}
 > %h<five> = %( this-keyย  => 'something' )
{this-key => something}
 > my $x
(Any)
 > with %h<five> { do with .<this-key> { $x = $_ } }
something
 > with %h<five> { do with .<this-key> { $x = $_ } }
===SORRY!===
Word 'with' interpreted as a listop; please use 'do with' to introduce 
the statement control word
at line 4
------> $ = withโ %h<five> { do with .<this-key> { $x = $
Unexpected block in infix position (two terms in a row)
at line 4
------> $ = with %h<five>โ { do with .<this-key> { $x = $_ } };

Note the lines begining with 'with'. Exactly the same line, executed 
twice, produces two significantly different answers.

I think this shouldn't happen.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About