Jeff Horwitz wrote:
the implicit return is by definition always at the end of a sub and therefore emits a PIR .return(). it's fast and easy.

the explicit return, in contrast, could be anywhere in a subroutine, including loops, closures, etc. these constructs are also implemented using parrot subs, so using .return() would return control to the sub that *contains* the loop, closure, or whatever construct you're using. that's not what we want.

to get around this, an exception is thrown and caught by the sub that *should* do the actual returning. you can see that in the PIR you generate.

(pmichaud, i hope i explained this right!  ;-)

-jeff

Thanks, I see now what is the difference. Probably we could optimize out the explicit returns when we reach the "optimization" phase of the project.
Best regards
luben

Reply via email to