From: "David A. Black" Date: 2004-10-05T01:13:55+09:00 Subject: Re: Too Many Ways? Hi -- On Tue, 5 Oct 2004 Ara.T.Howard@noaa.gov wrote: > On Mon, 4 Oct 2004, David A. Black wrote: > > > I have to admit (and my lack of C++, Java, etc. is probably showing through > > here -- i.e., I'm perfectly willing to believe there's something fundamental > > I'm just missing), I have never understood the idea of differentiating > > methods by number of arguments. To me it's sort of like differentiating > > them based on what letters the argument names begin with. What if two > > slightly different forms of the method both, by chance, took three > > arguments? Would one add a dummy argument? > > no - because you would also have a different signature (else the methods > wouldn't be 'slightly different' (probably) : > > // > // move from src to preallocated dest - leaving src untouched > // > int move (const char * const src, const char * dest); > > // > // move from src to dest - creating dest and freeing src > // > int move (char * src, char * dest); > > the idea is this - the compiler can tell you two things about your methods at > compile time : the types of the arguments and the number of them. [snip rest of very informative summary] OK, the examples with compile-time type checking explain why it might exist in other languages, and also why it continues to feel like a bad fit for Ruby. > it can use > this infomation to generate a case statement for you - eg it can know which > one to call freeing you from writing code like > > case argv.size > when 2 > arg0, arg1 = argv > case arg0 > when String > ... > end > when 3 > ... > ... > end I hope I'm already free of that, so that's another reason why I haven't felt the need for this :-) Thanks -- David -- David A. Black dblack@wobblini.net