From: Brian Candler Date: 2003-04-12T03:25:47+09:00 Subject: Re: Need IO Optimization help On Sat, Apr 12, 2003 at 01:40:57AM +0900, Austin Ziegler wrote: > On Fri, 11 Apr 2003 19:59:28 +0900, Brian Candler wrote: > > But Ruby has some fundamental disadvantages compared to Perl for > > this sort of program. For example, count += 1 requires a method > > dispatch, > > I've been thinking about this a bit since the last time the "++" > debate came up; the primary use for "++" is "count += 1", at least > in Ruby and Perl; might there be a call for a "Counter" class that > performs a similar purpose, but keeps the counting internal until > #value is called? I guess you'd have to call mycounter.inc in which case there's still a method call involved. So the only difference between that and mycounter = mycounter.+(1) is the passing of an extra argument, and assigning an object reference to a variable. My gut feeling is that both of those are fast operations. You can eliminate the extra argument by doing mycounter = mycounter.succ Cheers, Brian.