[% setvar title No special UPPERCASE_NAME subroutines %]

This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit http://www.perl6.org/

TITLE

No special UPPERCASE_NAME subroutines

VERSION

  Maintainer: Ilya Zakharevich <ilya@math.ohio-state.edu>
  Date: 15 Sep 2000
  Mailing List: perl6-language@perl.org
  Number: 243
  Version: 1
  Status: Developing

ABSTRACT

This RFC proposes that no subroutines with uppercased names should be special in Perl.

DESCRIPTION

If some special action handler needs to be registered, this should be done not by using a special name, but by a pragma.

  use tie STORE => sub { ... };

not

  sub STORE { ... }

This would make declarations of handlers visually distinctive, would avoid prolifiration of hundreds of special names for handlers, would avoid conflicts with interfaces to external libraries which define a STORE() funcation etc.

MIGRATION ISSUES

Translate currently special names to the corresponding pragmas, as shown above. (BEGIN/END etc. are proposed to drop sub in RFC68, so they are not covered by this RFC.)

IMPLEMENTATION

This way to introduce the handlers is already used with overloading. Keep in mind that the overhead of calling an overloaded method is 4..5 times lower than the overhead of calling the tie()d method (when the semantic is the same, for example, when comparing a scalar FETCH with the overloaded '~'.)

Currently overloaded methods live in the symbol table, but are converted to not-completely-alphanumeric names. A similar way may be used for other handlers introduced by pragmas, so they may continue to be inheritable if needed. For example, the above subroutine for STORE may live under the name 'tie/STORE'.

REFERENCES

RFC 68 (v2): Eliminate the optional sub for BEGIN etc block declarations