> Hi everybody,
> 
> That was nice to meet many of you in person at YAPC::EU,
> 
> I am trying to learn about continuations and Parrot. I hit a
> problem of register allocation. I don't know if it is a
> miscomprehension from me or a bug. Probably the former.
> Apparently P16 is used both for my Perlhash and the Sub.
> Below are the beginning of a pdb session and the PIR listing.
> 
> --
>   stef
> 
> 
> (pdb) l
> 1  new_p_ic P16,23
> 2  newsub_p_ic_ic P16,31,31
> 
> 
> .local PerlHash penta2d
> .const string str_nm = "U"
> 
> .sub _main
>       new penta2d, .PerlHash

Miscomprehension, but a very common one.  IMCC .local variables aren't
closed upon, so you can only use them within a single sub (in this
case, the outer sub which has no enclosing .sub/.end).  So, either
pass it as a parameter or set a global or lexical with its value.

I think we should remove nested subs from imcc, because they aren't
buying us anything and are only causing confusion. 

Luke

>         .local Sub sub
>         .local Continuation cc
>         newsub sub, .Sub, _mk_one
>         newsub cc, .Continuation, ret
>         .pcc_begin prototyped
>         .pcc_call sub, cc
> ret:
>         .pcc_end
>         
>         end
> .end
> 
> .pcc_sub _mk_one
>        .local int test
>        exists  test,  penta2d[str_nm]
>        invoke P1
> .end

Reply via email to