--pgp-sign-Multipart_Fri_May_30_03:36:48_2008-1
Content-Type: text/plain; charset=US-ASCII

At Fri, 30 May 2008 02:35:56 +0900,
David Flanagan wrote:
> I wouldn't call myself a "supporter" of nitems, though I'm a little
> surprised it is being removed without being deprecated first. I agree
> that it is a strange feature--the kind of thing that a C programmer
> without dynamic arrays might want.

Array#nitems was extended to take a block, and soon later
Enumerable#count was added.  I recently found during backporting to
1.8 that they do the same, so I suggested backing out #nitem's
extension and also pointed out that the original feature of #nitem was
not very useful, which the creators agreed.  That's what happened on
ruby-dev and why I rushed to removal.  Sorry for taking you by
surprise.

> I've re-thought my position. If nitems is so strange that it should be
> removed, then it doesn't make sense to transfer that strange behavior
> to a new method. Conversely, if compatibility is so important that
> porting nitems is a concern, then we should just keep nitems.
>
> In neither case does it make sense to patch the count method the way I
> proposed.  So I retract the patch I sent.  Sorry.

No need to feel sorry.  You posed the right question at the right time
before the 1.8.7 release.  Thank you.

> > 1) counting the number of all elements (the same as size/length for Array)
>
> This would probably be more useful than returning an Enumerator.
>
> Note that in the case of Enumerable#count, it is more than just an
> alias for size/length: it defines new functionality for enumerable
> objects like ranges. Is it necessary to define Hash#count so that it
> has similar performance characteristics to size when invoked without
> arguments on a hash?

Yes, Array and Hash should override the method for performance.  I'll
handle it tomorrow.

Regards,

--
Akinori MUSHA / http://akinori.org/

--pgp-sign-Multipart_Fri_May_30_03:36:48_2008-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEABECAAYFAkg+98AACgkQkgvvx5/Z4e5QpACggR7DOFms5uX+hGgd99SSEpmd
mHcAmwXcX2FvPstrtCoRTZMYon+FArJX
 ¨Â-----END PGP SIGNATURE-----

--pgp-sign-Multipart_Fri_May_30_03:36:48_2008-1--