Michal Wallace wrote:
[snip]
>       def f():
>           return g()
[snip]
> # f from line 3
> .pcc_sub _sub1 non_prototyped
>     .local object res1            # (visitReturn:528)
>     find_lex $P2, 'g'             # (callingExpression:325)
>     newsub $P3, .Continuation, ret0# (callingExpression:331)
>     .pcc_begin non_prototyped     # (callingExpression:332)
>     .pcc_call $P2, $P3            # (callingExpression:335)
> ret0:
>     .result res1                  # (callingExpression:338)
>     .pcc_end                      # (callingExpression:339)
>     .pcc_begin_return             # (visitReturn:530)
>     .return res1                  # (visitReturn:531)
>     .pcc_end_return               # (visitReturn:532)
> .end

Does python allow tail calls to be optomized?  That is, would it be
legal python semantics if f were to become:

.pcc_sub _sub1 non_prototyped
    find_lex $P2, 'g'
    .pcc_begin non_prototyped
    .pcc_call $P2, P1
    .pcc_end
.end

(untested)
Also... why is $P2 merely an imcc temporary, without a real name?  That
is, why not do:

.pcc_sub _sub1 non_prototyped
    .local object sub1
    find_lex sub1, 'g'
    .pcc_begin non_prototyped
    .pcc_call sub1, P1
    .pcc_end
.end

The more different prefixes you use ("res", "sub", "$P"), the lower the
numbers you'll need to append to them to make the names unique.  Not to
mention, it'll make the generated code more meaningful.

Another advantage is that with '.local' names, if you accidentally use a
name declared in one subroutine, in another, imcc will consider this to
be an error.  Such a mistake might be otherwise difficult to spot.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "[EMAIL PROTECTED]
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Reply via email to