Patrick writes -
Checking via isinstance() shouldn't be too difficult. But it may not even benecessary.
No. And would work fine, I'm sure, if I wasn't doing as much experimentation and on the fly kind of stuff as I go. Even if a bit messy, at least I know I don't need to worry about this kind of thing as a performance issue of significance, if I can limit the isinstance checking to the initialization routine. I *am* sensitive to trying to keep that kind of thing out of any update cycle where possible, as the app is graphical and dynamic and performance can be an issue. Perhaps I am just being somewhat lazy in my approach - and I need to be doing more of this upfront as I go along.
So, I am beginning to try to digest the meaning and significance of "multimethods" - for which there are Python modules.
I found one at http://www.sff.net/people/neelk/open-source/Multimethod.py. Is that the same one you are talking about?
And one at: http://bent-arrow.com/python which I'm thinking is more recent and under more active development - but I'm not sure.
Multimethods appear to be exactly what you are asking for. But I'm not sure they are the right thing to be asking for, if you know what I mean. :-)
Let's look at your example of an Intersection constructor and the variations you want to support:
Intersection(plane,line) Intersection(line,plane) Intersection(line,line)
What I'd ask is why do you need to know the types of the two parameters? At what point does it matter? What method(s) of Intersection need to function differently in each of the three cases?
I think we need to see more code to figure out whether this can't be handled without too much regard for object types. And even if some type checking needed to take place, multimethods seem like overkill to me.
Well, I am senstive to taking the discussion too far off topic to edu-sig - though I do have every intention of doing my best to pick your brain off list. Art