Created
July 6, 2011 17:50
-
-
Save tadzik/1067867 to your computer and use it in GitHub Desktop.
Once nqp, twice the bacon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An extract from SymbolTable.pm: | |
method add_constant($type, $primitive, *@value, *%named) { | |
for %named { | |
say("key: ", $_.key, "; value: ", $_.value); | |
} | |
... | |
say("cache_key: ", $cache_key); | |
... | |
} | |
Now the code firing it: | |
say("creating an array"); | |
my $content := $*ST.add_constant( | |
'Array', 'type_new', $cheatpast<compile_time_value> | |
); | |
say("produced: ", $content<compile_time_value>); | |
# XXX /CHEAT | |
my $past := $*ST.add_constant( | |
'Pod__Block__Named', 'type_new', | |
:name($name<compile_time_value>), | |
:content($content<compile_time_value>), | |
); | |
Produces: | |
creating an array | |
cache_key: Array,type_new,bacon | |
produced: bacon bacon | |
key: name; value: otherpod | |
key: content; value: bacon bacon | |
cache_key: Pod__Block__Named,type_new,name,otherpod;content,bacon bacon; | |
Somehow add_constant gave me twice the bacon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment