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

=head1 TITLE

Fix print "$r->func" and $pkg::$var precedence

=head1 VERSION

   Maintainer: Nathan Wiger <[EMAIL PROTECTED]>
   Date: 14 Aug 2000
   Version: 1
   Mailing List: [EMAIL PROTECTED]
   Number: 103
   Status: Developing

=head1 ABSTRACT

Currently, attempting to use objects in a string context
yields garbage:

   print "r is $r->func";     # "OBJ=HASH(0xef958)->func"
   print "r is ", $r->func;   # works, but clumsy

In addition, trying to dynamically assign to unnamed classes
is very difficult:

   $pkg::$var = $val;         # error
   ${"${pkg}::$var"} = $val;  # works, but bleeech!

The precedence and parsing of these operators should be fixed to allow
these important operations.

=head1 DESCRIPTION

=head2 Printable objects

This should print out correctly:

   $r = new Class;
   print "$r->func";

This would make it consistent with hashrefs and arrayrefs, which already
work correctly in string contexts.

Note that both this RFC and RFC 49 propose changes that make an object's
debugging info hard to get to. The next version of RFC 49 will include
an operator for easily accessing that information. Please see it for
details.

=head2 Dynamic package names

Currently, assigning values to dynamically-created package names is,
frankly, and pain in the butt. Major. These should work in Perl 6:

  $pkg = 'Class';
  $var = 'DEBUG';
  $pkg::$var = 1;

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

Currently, the precedenence of :: vs. symbolic references does not allow
these operations.

=head1 IMPLEMENTATION

I'll leave that to the internals guys. :-) 

=head1 REFERENCES

RFC 49: Objects should have builtin stringifying STRING method

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


Reply via email to