Jonathan Lang wrote:

How important is it that perl 6 maintains the notion that $foo and
@foo are entirely different things?


Very.


Also, there's the matter of "unneccessary paperwork": if the only
thing that I use the return value for is a boolean test, then all of
the effort involved in loading the filenames into a list was wasted
effort.  Is there a way that the "lazy evaluation" concept could be
extended to function return values?   Something like:


Partial Perl 5 implementation:

    sub chmod {
        my ($mode, @files) = @_;

        $mode = _normalize_mode($mode);

        my @failed;
        FILE:
        for my $file (@files) {
            next FILE if chmod $mode, $file;
            push @failed, $file;
        }

        use Contextual::Return;


# at this point, have the sub temporarily suspend operation.


        return
           BOOL   { [EMAIL PROTECTED]  }
           SCALAR { [EMAIL PROTECTED] }
           LIST   { @failed   }
    }

You haven't studied the Contextual::Return module closely enough. Lazy evaluation of the different return contexts is precisely what it already does. :-)

Damian

Reply via email to