Re: RFC 97 (v1) prototype-based method overloading
[email protected] (Chaim Frenkel) 14 Aug 2000 18:07:05 -0400
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "ABH" == Ask Bjoern Hansen <[email protected]> writes: >> =head1 ABSTRACT >> >> When I read the chapter on OO in the second edition camel book I >> was saddened that C++ style method overloading was not explicitly >> described. Ever hopeful, I wrote some quick code that I hoped would >> do what I meant and discovered that it didn't. This document is >> an attempt to remedy the situation. >> >> =head1 SUMMARY >> >> $frog_t = qs(frog); >> sub listargs($){ print "One arg, $_[0]"} >> sub listargs($$){ print "Two args, $_[0] and $[1]"} >> sub listargs($$frog_t){ print "$_[0] and a frog $[1]"} >> sub listargs { throw argsyntax, "odd arguments to listargs" } Please do not do this. It is a mess. Action at a distance. There are otherways to solve the same problem. Why would anyone want to select a different method based upon the arguments. The calling routine can easily dispatch differently. <chaim> -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183