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;

-or the identical -

    my bool $x;
    return $x if $x = &result_of_some_big_long_calculation(...args...);

Is there a way that doesn't require the named variable? Perhaps using C<when>? Just a thought experiment on my part, reduced from some code examples that do this sort of thing in a duplicitous fashion, switch-like...

    my bool $x;
    return $x if $x = &calc_try_1(...);
    return $x if $x = &calc_try_2(...);
    return $x if $x = &calc_try_3(...);
    ...

MikeL



Reply via email to