HaloO,

Luke Palmer wrote:
On 8/10/05, TSa <[EMAIL PROTECTED]> wrote:

Here is an example of a 2D distance method

  role Point
  {
    has Num $.x;
    has Num $.y;
  }
  method distance( Point $a, Point $b --> Num )
  {
     return sqrt( ($a.x - $b.x)**2 - ($a.y - $b.y)**2);
  }
[..]
# This one is quite a bit more dubious than the last
Array[Num] where { .elems >= 2 } does role {
    does Point;
    method x () is rw { ./[0] }
    method y () is rw { ./[1] }
}

That subtype would have to be an "auto-subtype", that is, it would
have to know that it is a member of that type without being told so.

Sorry, I do not regard it as dubious. It perfectly illustrates my
point that every instance/object/entity can qualify for an arbitrary
number of types because it is the types who define what belongs to
them and what not. What makes (2**31 - 1) a prime number? And what
excludes it from evenness? Is it a Fibonacci number? Is it a Complex?
Or an Octonion? Who has made Badgad a member of the AxisOfTheEvil
and bound it as invocant to a self declared .rescue method?

Don't get me wrong. My last question there is just for provoking
emotions. I'm making no judgement. That is left to a far more powerfull
entity than me on hmm, $day.does(Judgement) :)
And don't ask me to which point in spacetime $day is bound!

Such subtypes can introduce major inefficiencies in the program, and
are best left either out of the language, or somewhere in the dark
depths of I-know-what-I'm-doing-land.

I claim the opposite. My distance method exists in namespace like any
other code object. When it comes to creating an invocation of it the
prospective invocants are already at Hand. So, no efficiency penalty,
yet. The applicability check is based on type information stored under
::distance and is at hand already and there are far more complicated
tests than an Array subtype check, an Array content type check combined
with a size check. The binding of two references per Point will hardly
constitute a problem either. And don't tell me that the potentially
lazy calculation, optimization and caching under ::distance of such
an applicability closure is beyond the capabilities of Parrot/Perl6.

For multi methods the above procedure will be carried out for all
potential targets of the invocation and nobody has complained about
inefficiencies there, yet. At least not about others than the ones
that inherently come with MMD itself.
--
$TSa.greeting := "HaloO"; # mind the echo!

Reply via email to