On Fri, Nov 08, 2002 at 08:35:00PM +1100, Damian Conway wrote: : What you want are conversion-to-(num|str|bool) methods: : : sub a_pure_func(Num $n) returns Num { : class is Num { : has Num $cache; : sub value { $n * $n } : method operator:+ ($self:) { +($cache //= value ) } : method operator:~ ($self:) { ~($cache //= value ) } : method operator:? ($self:) { ?($cache //= value ) } : }.new : }
Just a nit, but those are probably prefix: rather than operator:, since we may need more clues than just the arguments to distinguish: prefix: infix: postfix: circumfix: (or should that really be outfix:?) Larry