in reply to Re^2: Why isn't return removed from optree?
in thread Why isn't return removed from optree?

Ah-ha! I found a situation where return can't simply be omitted.

>perl -MO=Concise,f -e"sub f { return ($x,$y) }" main::f: 6 <1> leavesub[1 ref] K/REFC,1 ->(end) - <@> lineseq KP ->6 1 <;> nextstate(main 1 -e:1) v ->2 5 <@> return KP ->6 2 <0> pushmark s ->3 - <1> ex-rv2sv sK/1 ->4 3 <#> gvsv[*x] s ->4 - <1> ex-rv2sv sK/1 ->5 4 <#> gvsv[*y] s ->5 -e syntax OK >perl -MO=Concise,f -e"sub f { ($x,$y) }" main::f: 6 <1> leavesub[1 ref] K/REFC,1 ->(end) - <@> lineseq KP ->6 1 <;> nextstate(main 1 -e:1) v ->2 5 <@> list KP ->6 2 <0> pushmark s ->3 - <1> ex-rv2sv sK/1 ->4 3 <#> gvsv[*x] s ->4 - <1> ex-rv2sv sK/1 ->5 4 <#> gvsv[*y] s ->5 -e syntax OK

That gives me something to look at.

Replies are listed 'Best First'.
Re^4: Why isn't return removed from optree?
by merlyn (Sage) on Dec 29, 2008 at 11:17 UTC
    But how are they different? Those both do exactly the same thing in both a scalar and list context, as far as I could tell.

      Are you suggesting that the optimizer should replace the return with list? I don't remember seeing it replace one op for another except in constant folding.