From: Jim Weirich Date: 2003-08-15T20:21:25+09:00 Subject: Re: Overloading () On Thu, 2003-08-14 at 14:10, Dave Benjamin wrote: > I'm the "Python guy" from comp.lang.functional. ;) I'd still like to > understand why the () operator can't be overloaded in Ruby, necessitating > the use of [] for Proc objects instead. What was the motivation behind that > restriction? Whenever someone says they would like to overload the () operator to make procs look like functions, I like to point out ... (1) Ruby doesn't have a () operator (2) Ruby doesn't have functions Of course, that's a bit of hand waving because certain method invocations certainly do _look_ a lot like function calls, and syntactic sugar is always an option. But Matz has given a more definitive answer elsewhere in this thread. But ... I'm wondering. Is there some idiom that would be facilitated by overloading ()? The only thing I can think of are C++ templates where the same bit of code might cause f in "f()" to be bound to a function name at one invocation or a functor object in another. Since Ruby doesn't have C++ like templates, this isn't an issue. I can't think of other useful scenarios, but then I'm probably insufficiently imaginative. -- -- Jim Weirich jweirich@one.net http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)