[% setvar title Sane resolution to large function returns %]
To see what is currently happening visit http://www.perl6.org/
Sane resolution to large function returns
Maintainer: Jerrad Pierce <belg4mit@mit.edu> Date: 17 Aug 2000 Mailing List: perl6-internals@perl.org Number: 127 Version: 1 Status: Developing
Perl has traditionally returned from various functions long (>3) lists of values. This can be somewhat frustrating, especially if you require one of the many datum returned. RFC 37 would have us break backward compatability to solve this "problem".
Functions like stat() and get*() return long lists of values. The implementation is assumedly easy: just push some values out of C structs into the Perl return stack.
This gives the end user a large list to deal with, which can be
unwieldy, especially when a single datum is desired. The typical
solution is to do something along the lines of (stat($file))[8].
Not elegant, but it works.
There has been a proposed new core function want(). this seems
to be generally regarded as a good thing. Fine. If it is implemented
we should use it. Offending functions (See RFC 37) should use
want() internally to determine what to return i.e; a list or a hash.
As for single datum access, perhaps function-[index]> or
function()-{key}> should be considered. This however, is not the
core of this proposal. Merely a possibility. Just as extending the
inelegant metaphor above to {function()}-{key}> would become a
possibility.
RFC 21: Replace wantarray with a generic want function
RFC 37: Positional Return Lists Considered Harmful