This is not quite finished yet, as I read the rest of the C-- garbage
collection paper.

-John

=head1 TITLE

Elements of @_ should be read-only

=head1 VERSION

  Maintainer: John Tobey <[EMAIL PROTECTED]>
  Date: 3 Aug 2000
  Version: 1
  Mailing List: [EMAIL PROTECTED]
  Number: 

=head1 ABSTRACT

Unprototyped subs should not be allowed to modify their callers' data
simply by assigning to elements of the arg array.  This form of
passing by reference is obsolete now that Perl has hard references and
C<\$> in prototypes.  The feature is confusing, since it means that
the recommended convention for naming parameters (by assigning C<@_>
to a C<my> list) alters semantics.

The Perl 5 (and older) behavior may preclude some optimizations.

=head1 DESCRIPTION

Bla bla bla, optimization.  Bla, bla, native code, pass by value.  C--
is cool.

=head1 IMPLEMENTATION

A fascist implementation would emit a compile-time error any time
C<@_> or one of its elements were assigned to, taken a refernce to,
etc.  A friendlier version would automatically copy the arg value to a
new temporary.

This change would mean a moderate Perl 5 compatibility breakage.  The
Perl-5-to-Perl-6 converter could insert whatever trick is used to
obtain the Perl 5 behavior (perhaps a C<(@)> prototype) when it
detects argument modification.

If the optimization suggested above is implemented, it would cause
another wave of breakage, as arg-modifying subs would have to be
defined or prototyped above the places where they are called.  A
pragma to restore the old behavior would be the safest guarantor of
compatibility.

=head1 REFERENCES

L<perlsub>, The C-- homepage - http://www.cminusminus.org/

Reply via email to