I was trying out macros and run into an anomaly. Not sure what is happening.

I tried a macro snippet as a standalone script, then tested exactly the same in REPL. It worked in REPL, as in the hash variable was changed. But the hash variable stayed the same in the stand alone. What am I missing?

Here is a paste from my terminal.

$ cat macro-test.p6
my %o;
macro attr ( $nm, $val ) { quasi { %o{ {{{$nm}}} } = {{{$val}}}  } }
%o.say;
attr 'fst', 42;
%o.say;
$
$ perl6
> my %o
().hash
> macro attr ( $nm, $val ) { quasi { %o{ {{{$nm}}} } = {{{$val}}}  } }
Nil
> %o.say
().hash
> attr 'fst', 42
42
> %o.say
("fst" => 42).hash
> ^C
$ perl6 macro-test.p6
().hash
().hash
$
$ perl6 -v
This is perl6 version 2013.11 built on parrot 5.9.0 revision 0


Reply via email to