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

=head1 TITLE

Fix C<$pkg::$var> precedence issues with parsing of C<::>

=head1 VERSION

   Maintainer: Nathan Wiger <[EMAIL PROTECTED]>
   Date: 14 Aug 2000
   Last Modified: 15 Sep 2000
   Mailing List: [EMAIL PROTECTED]
   Number: 103
   Version: 2
   Status: Frozen

=head1 ABSTRACT

Currently, trying to dynamically assign to unnamed classes is very
difficult:

   $pkg::$var = $val;         # error
   ${pkg}::$var = $val;       # nope
   ${$pkg::$var} = $val;      # you wish
   ${${pkg}::$var} = $val;    # sorry
   ${"${pkg}::$var"} = $val;  # works, but bleeech :-)

The precedence and parsing of the :: operator should be fixed to allow
easy access to anonymous package operations.

=head1 NOTES ON FREEZE

The first part of this RFC, interpolated method calls, was superceded by
RFC 222: "Interpolation of method calls", by Michael Schwern.

=head1 DESCRIPTION

In a perfect world, these should work in Perl 6:

  $var = 'RaiseError';
  $DBI::$var = 1 ;               # $DBI::RaiseError = 1

  $pkg = 'Class';
  $var = 'DEBUG';
  ${${pkg}::$var} = 1;           # $Class::DEBUG = 1

  $subpkg = 'Special';
  $class = $pkg . '::' . $subpkg;
  require $class;                # require Class::Special

  $mypkg = 'Some::Package::Name';
  $ret = $mkpkg::do_stuff(@a);   # is &{"${mypkg}::do_stuff"}(@a) now  

Currently, the precedence of :: does not allow these operations. Some of
the above examples may still require additional braces, but they
shouldn't require the types of contortions currently needed.

=head1 IMPLEMENTATION

Unfortunately, I don't have the time to think this part up yet. :-( I
will gladly contribute to the precedence and parsing rules discussions
that will ensue in the future if this RFC is accepted.

=head1 REFERENCES

Programming Perl, 2ed, for the ${"${pkg}::$var"} syntax

RFC 222: Interpolation of method calls

Reply via email to