This and other RFCs are available on the web at
  http://tmtowtdi.perl.org/rfc/

=head1 TITLE

Positional Return Lists Considered Harmful

=head1 VERSION

  Maintainer: Jarkko Hietaniemi <[EMAIL PROTECTED]>
  Date: 04 Aug 2000
  Version: 1
  Mailing List: [EMAIL PROTECTED]
  Number: 37

=head1 ABSTRACT

Perl has traditionally returned from various functions long (>2) lists
of values.  Some traditions are simply bad.

=head1 DESCRIPTION

Functions like stat() and get*ent() return long lists of mysterious
values.  The implementation is assumedly easy: just push some values
out of C structs into the Perl return stack.

Wrong.  And once more, wrong.

Firstly, who can remember which one of the stat() return values was
the atime is or which is the 4th return value of localtime()?  The
perlfunc documentation makes this difficulty painfully obvious by
having to list the indices alongside the values.

Secondly, the current solution is seriously non-extensible.  One
cannot easily add new return values to the APIs because someone may be
expecting an exact number of return values, or someone may be
accessing the values by position from the end of the list Obsoleting
values (or marking them as non-applicable to the current platform) has
to be done by for examples returning undef.

=head1 IMPLEMENTATION

The solution is simple: return hashes instead of lists.  Yes, one
still has to know how the fields are named, so the proposed solution
is still not perfect.

=head1 REFERENCES

  perlfunc
  File::stat
  User::grent
  User::pwent
  
  

Reply via email to