Michael Lazzaro writes: > Forgive me; a very minor style & efficiency question... what would the > canonical way to do this be, given what we know of Perl6? > > # the hapless, inefficient version: > return &result_of_some_big_long_calculation(...args...) > if &result_of_some_big_long_calculation(...args...); > > The obvious answers are this: > > my bool $x = &result_of_some_big_long_calculation(...args...); > return $x if $x;
That does something different, in that it has coerced the result into a C<bool>[*0]. So after the first line C<$x> can only be 0 or 1[*1]. And given that one of those states is false, the code becomes equivalent to: my bool $x = &result_of_some_big_long_calculation(...args...); return 1 if $x; or simply: return 1 if &result_of_some_big_long_calculation(...args...); However if you permit the function to return more than two different values (of which more than one are true) then it becomes a more interesting question. [*0] Do we have C<bool>? I thought Larry wanted C<bit>. [*1] Or whatever the two states of a C<bool> are. Smylers