[Numpy-discussion] A little help please?

Damian Eads eads@soe.ucsc....
Fri Feb 29 05:02:05 CST 2008


Neal Becker wrote:

> Sounds like this needs a bit of re-thinking.
> 
> Given a set of function signatures:
> F(a,b,c)
> F(d,e,f)
> ...
> 
> The user calls:
> F(A,B,C) (no relation between a,A ,etc)
> 
> How do we find the 'best' match?
> 
> I think we can start with:
> Rules:
> 1) Only allowed (at most) 1 conversion on each argument
> 
> But what is the 'best' match mean?
> 
> I think that can't be decided without some sort of hierarchical relation of
> the types.
> 
> Now given a hierarchy, I still don't know the solution, but it sounds like
> some kind of graph algorithm.

Dear Neal,

This response is probably a bit off-topic but I thought I'd provide this 
nugget to help guide your search for information.

This topic has been heavily studied by theoretical computer scientists. 
  Benjamin Pierce's Types and Programming Languages (MIT Press, 2002) is 
an excellent text gives a detailed review of the state of the art in the 
field of Type Systems.

Finding the "best" match or an unambiguous one can be difficult 
depending on how the language is defined. Many type systems are defined 
by a set of typing rules and axioms. Types of expressions are often 
resolved by generating a proof that these rules are met. I've always 
found the subject of static typing interesting because it deals with how 
to make type guarantees of a program before it is evaluated or compiled.

The subject to which you're referring is called dispatch. Many common 
OOP languages (e.g. C++, Java) support only a rudimentary dispatch 
algorithm where the method branch chosen for dispatch is determined at 
run-time by examining the type of the target object on which the method 
is invoked. The types of the arguments are only examined statically at 
compile or type-check time. Languages supporting multiple dispatch 
(variants of Java like MultiJava, Charming Python, etc.) examine the 
types of the arguments at run-time, and some multimethod type checkers 
can prove whether a program will ever encounter an ambiguous choice 
between branches before the program is ever run or compiled.

I hope this helps.

Damian


More information about the Numpy-discussion mailing list