I'd really love to see Any support something like this:

diff --git a/src/core/Any.pm b/src/core/Any.pm
index dd6a84b..081f42d 100644
--- a/src/core/Any.pm
+++ b/src/core/Any.pm
@@ -13,6 +13,17 @@ augment class Any {
         note "Use of uninitialized value in numeric context";
         0;
     }
+
+    method help() {
+        my @msg;
+        if self.^can("WHY") {
+            @msg.push(self.WHY);
+        }
+        @msg.push("Type: " ~ self.WHAT);
+        @msg.push("Methods: " ~ (self.^methods.map: ~*).sort.join(", "));
+        return @msg.join("\n");
+    }
+
 }

 # vim: ft=perl6

I know that S26 will save my life and make my apple pie taste better, but
just for now, it would be really, really handy to be able to stop typing
"./perl6 -e 'say ("".^methods.map: ~*).sort.join(", ")'" every time I forget
what "samecase" is called.

I added in the speculative call to .WHY, just for some minor future-proofing
against S26, but someone closer to that effort could probably tell me what
that should really look like.

PS: I'll admit I don't understand S26's .WHEREFORE and maybe that's supposed
to do the same thing as my .help, or perhaps it's saying that metaclasses
stringify to my .help? Not sure. Still, it would be cool to have this kind
of thing sooner, rather than later.

PPS: It would also be nice if .Str worked on everything, because then the
above would be:

  @msg.push("Methods: " ~ self.^methods>>.Str.sort.join(", ");

which currently fails:

  get_attr_str() not implemented in class 'Perl6MultiSub'

Or perhaps there should be a unary ~ equivalent as a method?

-- 
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs

Reply via email to