Hi,
Rob Kinyon wrote:
> On 11/20/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
>> Yep. Also note that "for" is not a special magical construct in Perl
>> 6, it's a simple subroutine (&statement_control:<for>, with the
>> signature ([EMAIL PROTECTED], Code *&code)). (Of course, it'll usually be
>> optimized.)
>>
>> Example:
>>
>> {
>> my sub statement_control:<for> ([EMAIL PROTECTED], Code *&code) {
>> map &code, reverse @array;
>> }
>>
>> for <a b c> -> $item { say $item }
>> # "c\nb\na\n"
>> }
>>
>> # for restored, as the modified for went out of scope:
>> for <a b c> -> $item { say $item }
>> # "a\nb\nc\n"
>
> Is there a list of the statement control items that are implemented as
> such vs. implemented in another way?
&statement_control:<if>,
&statement_control:<unless>,
&statement_control:<for>,
&statement_control:<while>,
&statement_control:<until>, and
&statement_control:<loop>
come to my mind.
??!! is proably defined as
sub ternary:<?? !!> ($cond, $then is lazy, $else is lazy) {
if $cond { $then } else { $else }
}
(Assuming that "ternary" is the correct grammatical category and "is
lazy" DWIMs.)
Of course, the compiler is free to optimize these things if it can prove
that runtime's &statement_control:<if> is the same as the internal
optimized &statement_control:<if>.
--Ingo