Hi,
I tried to implement a method postcircumfix:<( )> for the Whatever type
so that you can write
@array.sort: *.(5)
to sort an array of closures by their return values when invoked with
the number 5.
I think the attached patch should do that, but when I try it I get:
$ ./perl6 -e 'say (*.(3)).WHAT'
Block()
$ ./perl6 -e 'say (*.(3)).(-> $x { say $x })'
Method 'postcircumfix:( )' not found for invocant of class 'Block'
So it does create a closure (not of type WhateverCode, because I don't
know how to rebless a block to a different class, but something callable
nonethelss), but it can't call it.
But shouldn't it usually call the invoke() vtable method instead of
trying to call a postcircumfix method? I'm rather confused now...
Cheers,
Moritz
>From 430407aa6c854029ddcd0953fc33152cc7af64c1 Mon Sep 17 00:00:00 2001
From: Moritz Lenz <ml...@wvbh074.physik.uni-wuerzburg.de>
Date: Thu, 13 Aug 2009 14:57:33 +0200
Subject: [PATCH] try to implement postcircumfix:<( )> on Whatever
---
src/setting/Whatever.pm | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/setting/Whatever.pm b/src/setting/Whatever.pm
index db240a9..0c27ec4 100644
--- a/src/setting/Whatever.pm
+++ b/src/setting/Whatever.pm
@@ -5,6 +5,9 @@ class Whatever is also {
method ACCEPTS(Any $topic) {
return Bool::True;
}
+ method postcircumfix:<( )>(*...@pos, *%named) {
+ return -> $x { $x(|@pos, |%named) };
+ }
}
# vim: ft=perl6
--
1.5.6.5