Re: RFC 161 (v2) OO Integration/Migration Path

[email protected] (Nathan Wiger)
Newsgroups perl.perl6.language.objects
Message-ID <[email protected]>
Steve Fink wrote:
>
> But then what does my $x = BlueFoo->new(); print
> "$x" do, assuming there is a BlueFoo::STRINGIFY? Print
> "BlueFoo=HASH(0x0b38134)"?

The current thinking it to preserve the default behavior, which would be
to print out the ref info, UNLESS there is a STRING function. That
STRING function would then print out whatever you set it up to print
out. See RFC 49 for more info.

So, if you defined BlueFoo::STRING as follows:

   package BlueFoo;
   sub STRING {
       return "Wazzzzzzaaaaap!!";
   }

Then your code would do this:

   my $x = BlueFoo->new;
   print "$x";            # prints "Wazzzzzzaaaaap!!"

Also, please note the sub is STRING. 10,000 emails went back and forth,
and STRINGIFY is too cute for non-English natives. It also requires we
do NUMMIFY or BOOLIFY instead of NUMBER or BOOLEAN. Too cute. 

See RFC 159 for more details on this.
 
> As for non-vtable methods, were you planning on making
> 
> my Foo $foo; $foo->method_not_in_Foo_package();

The identical Perl 5 behavior and error of:

   Can't locate method method_not_in_Foo_package via package $foo

Should apply here.

-Nate
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.