Hi,

just checking: Are anonymous macros allowed?

  my $macro = macro ($x) { "100$x" };
  say $macro(3); # 1003

Of course, anonymous macros can't be called at compile-time, like normal
macros:
  my $macro = rand < 0.5
    ?? macro ($x) { "100$x" }
    :: macro ($x) { "200$x" };
  say $macro(3); # 1003 or 2003?

But they're still useful if I want to work with $macro references and
store them later, at compile-time, in a &-var:
  my &macro = BEGIN {
    rand < 0.5
      ?? macro ($x) { "100$x" }
      :: macro ($x) { "200$x" };
  };
  say macro 3; # reduced at compile-time to either 1003 or 2003


--Ingo

-- 
Linux, the choice of a GNU | The computer revolution is over. The
generation on a dual AMD   | computers won. -- Eduard Bloch <[EMAIL PROTECTED]>
Athlon!                    | 

Reply via email to