&CORE::select()
authorFather Chrysostomos <sprout@cpan.org>
Sat, 27 Aug 2011 16:50:22 +0000 (09:50 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Aug 2011 00:47:14 +0000 (17:47 -0700)
commit720d5b2f3eeadadafefee42d92b2093b9688f9c1
tree31bb1dd273454f81d37b79e946984958742e196c
parent0d043efa5001bcca81315a3a7a5ec260f9b378ff
&CORE::select()

This commit allows CORE::select to be called through references and
via &ampersand syntax.

This is a tricky case, as the select keyword represents two distinct
operators.  ck_select replaces the OP_SELECT with an OP_SSELECT if
there is more that one argument.

So what we do here is create an if(@_>1)/else block with the usual
op-with-coreargs-child inside each branch.

The op tree looks like this:

$ ./perl -Ilib -mO=Concise,CORE::select -e 'BEGIN{\&CORE::select}
'
CORE::select:
8  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <1> null K/1 ->8
5        <|> cond_expr(other->6) K/1 ->9
4           <2> gt sK/2 ->5
2              <1> rv2av[t4] sK/1 ->3
1                 <#> gv[*_] s ->2
3              <$> const[IV 1] s ->4
7           <@> sselect[t2] K ->8
-              <0> ex-pushmark s ->6
6              <$> coreargs(IV 218) ->7
a           <@> select[t1] sK/1 ->8
-              <0> ex-pushmark s ->9
9              <$> coreargs(IV 219) s/DREF1 ->a
-e syntax OK

There was no need to modify pp_select to handle a null when there is
no argument, as it can already handle it.
gv.c
op.c
t/op/coreamp.t