HaloO,

Daniel Ruoso wrote:
Em Qui, 2009-03-05 às 18:43 -0800, Jon Lang escreveu:
And more generally, would there be a
reasonable way to write a single routine (i.e., implementation) that
could be invoked by a programmer's choice of these calling
conventions, without redirects (i.e., code blocks devoted to the sole
task of calling another code block)?

This is exactly what this change has enabled. Now it doesn't matter if
your signature had an invocant or not, if that code is available as a
method it can be dispatched as a method, if it is available as a sub, it
can be dispatched as a sub, which means that you can install a sub as a
method and a method as a sub, it doesn't mattter...
[..]
semantically, yes... but I don't think there's a syntax to bind a sub as
a method... You need to do it through the meta api at this moment...

With this nice unification of sub and method as far as the binder
is concerned I wonder how one implements methods for classes one
is supertyping from without an is also clause. With the venerable
example of Complex supertyping Num we should have

   method im (Num $x:) { return 0 }
   method re (Num $x:) { return $x }

outside of any class and nonetheless allow the method invocation
syntax 3.im without the object slot dispatcher complaining. That
is I want to avoid

   class Num is also
   {
      method im { return 0 }
      method re { return self }
   }

at least as syntactical form. I think in the end the class Num
gets the additional methods one way or another. But it seems
open classes have acquired a design smell of late. Or why is
the process called monkey patching?


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to