develooper Front page | perl.perl6.users | Postings from October 2018

Strange output on 'say Foo::Bar::<&zape>;'

Thread Next
From:
Richard Hogaboom
Date:
October 11, 2018 13:36
Subject:
Strange output on 'say Foo::Bar::<&zape>;'
Message ID:
0b8170ee-1707-fd24-c310-f28d7c9bd510@gmail.com
#
# example from https://docs.perl6.org/language/packages
#
# from documentation under Package-qualified names:
#
# "Sometimes it's clearer to keep the sigil with the variable name, so 
an alternate way to write this is:
# Foo::Bar::<$quux>
# (This does not work with the &zape variable) The name is resolved at 
compile time because the variable name is a constant."
#
# So, I tried &zape, which gives the expected error output. However, it 
suggests possible corrections, which I tried.
# say Foo::Bar::<&zape>; should also fail, but compiles, executes, does 
nothing, gives strange msg
#

use v6;

class Foo {
     class Bar {
         our &zape = { "zipi" };
     }
}

say Foo::Bar::zape;  # works - prints 'zipi'

# this should not compile - see error msg below
#say Foo::Bar::&zape;  # Nope - it does not compile - correct

# ===SORRY!=== Error while compiling 
/home/hogaboom/hogaboom/Perl6/p6ex/./p6Packages.p6
# Malformed lookup of ::&zape; please use ::('&zape'), ::{'&zape'}, or 
::<&zape>
# at /home/hogaboom/hogaboom/Perl6/p6ex/./p6Packages.p6:12
# ------> say Foo::Bar⏏::&zape;  # Nope - not compile - correct

# this also should not compile
say Foo::Bar::<&zape>;  # compiles - executes - does nothing useful - 
gives following strange output
say Foo::Bar::{'&zape'};  # compiles - executes - does nothing useful - 
same strange output
#say Foo::Bar::('&zape');  # does not compile

# -> ;; $_? is raw { #`(Block|62717656) ... }
# what does this output mean?

say "end";  # prints 'end'

-- 
rahogaboom

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