On Tue, May 25, 2004 at 06:15:24PM +0900, Gavin Sinclair wrote:
> I think that if we are to support this Numeric#of idea, then the above
> example is (inadvertently) the best.
> 
>   a, b, c, d, e = 5.times { Array.new }
> 
> is more intuitive to me than
> 
>   a, b, c, d, e = 5.of { Array.new }
> 
> I know Integer#times is already implemented, but supporting the above
> would now be incompatible.  At the moment, 5.times { whatever } returns 5.
>  Surely nobody depends on that behaviour?  #times is used for its

I do make a number of assumptions regarding Integer#times; specifically,
I expect it not to collect the result of the expression: what if a large
temp. object is created there? Would I have to add  ; nil so that it
can be GCed?

> side-effects, not its return value.

IMHO this
  100000.times{ ... }
would be way more common than
  a, b, c = 3.times{ [] }

I certainly do *not* want an array to be created in the 1st case.
That extension would render Integer#times unsuitable for iteration,
performance-wise.

I'd rather keep Integer#times as it is, and use the 
  a, b, c = (1..3).map{[]} 
idiom; I don't think the use case deserves polluting the language (in the
case of 'of', by being too generic) or a potentially big performance hit,
for a minimal gain.

Don't get me wrong, I love adapting the language to the problem space
(I (ab)use metaprogramming often) but IMHO in this case it just doesn't
pay off.

-- 
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

MSDOS didn't get as bad as it is overnight -- it took over ten years
of careful development.
	-- dmeggins / aix1.uottawa.ca