On Fri, Mar 12, 2004 at 03:47:57AM -0500, Austin Hastings wrote: : > -----Original Message----- : > From: Larry Wall [mailto:[EMAIL PROTECTED] : > On Thu, Mar 11, 2004 at 11:38:11AM +0000, Andy Wardley wrote: : > : Larry Wall wrote: : > : > multi sub *scramble (String $s) returns String {...} : > : [...] : > : > Or you can just call it directly as a function: : > : > scramble("hello") : > : : > : Can you also call scramble as a class method? : > : : > : class String is extended { : > : method scramble { ..etc... } : > : } : > : : > : String.scramble("hello") : > : > Not unless you write a class method that takes an extra argument. : > Otherwise you're passing a class where it expects a string, and a : > string where it expects nothing. However, much like in Perl 5 you : > can always force which class's method to call with : > : > "hello".String::scramble(); : : But it would work as a "class multi", right? : : class String is extended { : multi scramble(String $s) {...} : }
You probably have to decide whether that's a multi sub or a multi method, at least syntactically. Though it may not matter which you pick because... : "hello".scramble(); : String::scramble("hello"); # Way overspecified for a multi... For a single argument function, those probably come out to the same thing in the end. With more arguments you have to start distinguishing single dispatch from multiple dispatch. Larry