Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created July 6, 2011 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadzik/1067867 to your computer and use it in GitHub Desktop.
Save tadzik/1067867 to your computer and use it in GitHub Desktop.
Once nqp, twice the bacon
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