Quoth [EMAIL PROTECTED]: ... | The first point is: Python has global functions, as well as methods. If | f(a) should look up f inside a first, that would shadow any global or | local f. That's bad, because python is dynamically typed, and you | sometimes down' know what "a" is. Things like "open(filename)" or | "tuple(a,b,c)" could behave completely unexpected, if "filename" had an | "open" or "a" a "tuple" attribute.
Well, of course we have to assume as part of the proposal that it would documented and actually would be expected, to the extent that one is entitled to expect anything in Python. It seems to me that if you bring an even slightly open mind to the question, when we apply "open" to an object that supports "open" with its own function, what could be more appropriate than to call that function? I will allow that there is some potential for problems here, but there may be ways to finesse them. Haven't thought real hard about it. | The other point is: Python supports named arguments. The algorithm to | put positional and named arguments into the right parameters is rather | tricky, and it _must_ know the function that's being called to work. | So, you simply can't make function lookup depend on the parameters, | it's a hen-egg problem. Ah. I see no reason this system needs to support a named first parameter, though, so I suppose a function application like f(a=x,...) would be exempt from parameter lookup. This seems like an implementation detail. | > Of course the whole business is kind of a joke, since there is no way | > anyone in their right mind would wish to change Python's notation for | > such trivial reasons, but there actually are languages that resolve | > functions based on argument types. Overloading in C++ is somewhat | > like this, Haskell's typeclass mechanism, and there is a ``multiple | > dispatch'' model that I have no experience with but is not without its | > supporters. | | Yes, but both C++ and Haskell are statically typed, and neither | supports named arguments. | (We're talking about one function operating on one object, so I don't | see what multiple dispatch has to do with this) Come on, you know that in the unlikely event this idea were to be seriously considered, someone would be hot to extend it to multiple objects before it even got implemented on one, but in any case, single dispatch sounds like just a restricted case of multiple dispatch, so if the latter is feasible, so is the former. I've heard talk about a form of static typing for Python, and obviously that has the potential to considerably enhance the possibilities in this area. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list