Re: RFC for $ME class variable (was Re: RFC 124 (v1) Sort order forany hash)

[email protected] (Nathan Wiger)
Newsgroups perl.perl6.language.objects
Message-ID <[email protected]>
Bart Lateur wrote:
> 
> >I hate it, it's miserable. Too much hidden trickery and special cases.
> 
> Quite the countrary, I should think. Have you seen the subs
> self_or_default and self_or_CGI in the source of CGI.pm? 

Yep, if you check out my File::Remote module I hijacked them. Thanks
again, Lincoln! :-)

This is exactly the thing we're trying to fix, so we're on the same
page.

>         my $self = self() && shift;
> 
> Now that is ugly.

Blech! You're right. This would be nasty. But that's not the way it
would work. :-)

Check out the RFC I just submitted on it. Basically, self() would always
return something worth using, just like $ME would have something worth
using. Nothing would be in @_:

   sub mysub {
       ($one, $two) = @_;
       print "Got one = $one, two = $two" if self->config('Debug');
   }
   self->mysub;     # main->mysub
   print "I'm not feeling my ", self, " today.\n"  # hah!

Kinda neat, eh? Check out the RFC, I think you'll like it.

-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.