From: Christoph Date: 2002-09-30T00:52:12+09:00 Subject: Re: adding overload to ruby "ts" wrote .... > C> I assume that you are wondering if using ambiguity > C> resolution makes is a big change in the use of multi-dispatch? > > Well, apparently you have not seen where is the problem. The problem is > easy to understand but difficult to solve : I'm stupid. Your ``stupidity'' is no match for mine (and it is definitely not a close call;-) - I really don't see any problems at all!! > > For example, with this case : > > pigeon% ruby -e 'def a(Array a, Object o) end; def a(Object o, String s) end' > -e:1: Possible ambiguous call [Array, Object] -- [Object, String] (NameError) > pigeon% Figuring out all ambiguities at compile time is impossible in a dynamic languages. For example, an overload declaration def a(Array a, Object o) end def a(Object o, String s) end def a(Array a, String s) end has no ambiguity at all (in any multiple dispatch mechanism) however this becomes only apparent after the third declaration! Also with a ambiguity resolution of one my previous post even def a(Array a, Object o) end def a(Object o, String s) end would never be ambiguous. But his not the point both Cecil (in the dynamic mode!) and Dylan flag this type of ambiguity at runtime - this just comes with the territory. > > It take me approximatively one hour to understand why it give an error > message and another hour to find the case where it has a problem. > > If it don't give an error message, it will exist case where I'll not > know what it do. (well I am probably dangerously close to becoming overly repetitive;-) Just follow Cecil's or Dylan's example. That is throw an exception at runtime - or use some sort ambiguity resolution (like picking the lexicographic larges among ``maximal applicable specialization"). /Christoph