Trey Harris asked:

This is eerily like Contextual::Return, which made me wonder if it's even required in Perl 6.

Obviously we can do

    return do given want {
              when :($) { ... }

But "return do given want" flows so badly, I desperately want some sugar for this. Is there some and I missed it?

No, the sugariest you'll find at the moment is probably:

    return         ?? $lvalue
        :: want.count == 2 ?? (7,11)
        :: want.item       ?? 42
        :: want.list       ?? 1..10
        ::                    die "Bad context;

but that still doesn't have the Awesome Power of C::R. ;-)

The simple answer is that C::R is probably the first module I will port to Perl 6 (since it's the module I find myself using the most nowadays). The Perl 6 version will be cleaner and more efficient that the Perl 5 version, since I'll be able to take advantage of macros.


Reply via email to