Why doesn't Perl 6 pairs and name interpolation work?

I played with Interpolation in names . I was more interested in this colon syntax function to turn a variable into a pair where the identifier is the key.

my %Hamadryas = map { slip $_, 0 }, < februa honorina velutina >; { my $pair = :%Hamadryas; say $pair; # Hamadryas => { ... } } put '-' x 50; 

But, just for a giggle, I also wanted to try with variable name interpolation. I know this is stupid, because if I know the name, I don't need the colon syntax to get it. But I also thought that it should work by chance:

 { my $name = 'Hamadryas'; # Since I already have the name, I could just: # my $pair = $name => %::($name) # But, couldn't I just line up the syntax? my $pair = :%::($name); # does not work say $pair; } 

Why is the syntax :%::($name) not working? It is a question of when the parser decides that it does not parse what it wants to understand. I decided that he would see : and begin processing the colon pair, and then see % and find out that it has a hash, although there :: after % .

Is there a way to make it work with grammar tricks and mutations?

+7
perl6
source share

No one has answered this question yet.

See related questions:

8
Why is declaring a Perl 6 loop variable in the outer scope?
8
What is allowed in the Perl 6 identifier?
7
What does the second colon in "List: D:" mean in Perl 6?
6
setting parsing return value, saving nameless terminals
5
Why does this perl 6 grammar not work?
5
How can I interpolate a variable in a Perl 6 regex?
4
Working with Images in Perl 6
4
cannot use a colon pair in `qqww` or` qqww: to` struct
3
Using a colon in a method and function call in Perl 6
2
How to interpolate variables in regex Perl 6 character class?

All Articles