From: Josh Cheek Date: 2011-01-18T10:32:19+09:00 Subject: Re: Why Ruby Does Not Support Method Overloading? --00163628369cc5fded049a14de9e Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jan 17, 2011 at 7:09 PM, Su Zhang wrote: > Common-Lisp does support multiple dispatch, but it does so by > including a type modifier to the arguments so that they can be checked > against the actual runtime type of arguments, which, IMO, is as > unpleasant as doing something like the following in a single method > definition: > > case arg > when String > # ... > when Symbol > # ... > end > > I went through a Lisp book over the winter break, and I took it a different way: that it was essentially a way to define a receiver for a function. (not sure if that is good terminology) In other words, I took it like: class Array def size Array size finding code end end class Hash def size Hash size finding code end end Now, hash.size invokes a different method than array.size. So in Lisp this would maybe look like (defmethod size ((self array)) array size finding code ) (defmethod size ((self hash-table)) hash-table size finding code ) And unlike all the other functions in Lisp, which share the same namespace, size knows which function to invoke (size ary) invokes a different function than (size hash). So I think that defmethod is an appropriate name, because that is how I consider them, modular like methods, as opposed to created in one canonical place like a case statement. --00163628369cc5fded049a14de9e--