Chip Salzenberg wrote:

    multi sub is_equal(Integer $a, Integer where { $_ == $a } $b: ) { 1 }

hurts.  At least as I've been given to understand it[*], is impossible
to implement, because the second parameter's type can't be precalculated
in order to prepare for MMD dispatching.

Quite interesting that Cecil already has it. The thing is called
Predicate Dispatch and there exist efficient implementation strategies.
And it is possible to calculate a static supertype of the above,
which is &is_equal:( Integer, Integer : ).

In short, $b has no pre-calculable type.  And you can't calculate the
MMD potential of a subroutine unless you know the actual types of its
MMD-participating parameters.

I don't know what 'MMD potential' is.

(This also means that the type of &is_equal:(...) is impossible to
express, unless I greatly misunderstand the &foo:() syntax.  But
it doesn't matter what you call it if you can't call it.)

The syntax might just be:

   &is_equal:(Integer $a, Integer where { $_ == $a } :)

The only point is that I see no way for the compiler to
optimize to anything but a dynamic dispatch. Thus a more
declarative style of predicate specification would be

PS: Of course this example also implies that each parameter's
    declaration introduces a new lexical scope to its right.

Well the colloquial spec of your function is just 'it takes
two equal integers'. And the two element list (3,3) is a
subtype of it.

TSa (Thomas Sandla▀)

Reply via email to