So, I'm trying to get my head 'round parrot's continuations. It's my
understanding that, at creation time, a Continuation closes over the
current user stacks, control stack and lexical pad (and possibly some
other stuff but those'll do for now). 

So, it seems to me that the following code should print "Howdy,
world". 

  .sub main
    $P0 = new PerlUndef
    $P0 = "Howdy, world\n"
    save $P0
    $P1 = newcont after
  #    $P1 = new .Continuation
  #    set_addr $P1, after
    invoker($P1)
  sub_end:
    .pcc_begin_return
    .pcc_end_return

  after:
    restore $P2
    print $P2
    branch sub_end
  .end

  .sub invoker 
    .param pmc a_cont
    invoke a_cont
    .pcc_begin_return
    .pcc_end_return
  .end

Except, what actually happens is: 

Parrot VM: PANIC: Illegal rethrow!
C file src/exceptions.c, line 356                                                 
Parrot file (unknown file), line 0

Which isn't quite what I had in mind. Bizarrely, if I do:

$ parrot -o howdy.pasm howdy.imc
$ parrot howdy.pasm
Howdy, world
$

everything's fine.

Weird hunh?

Reply via email to