On Mon, Dec 1, 2014 at 10:29 AM, Eliot Miranda eliot.miranda@gmail.com wrote:
On Mon, Dec 1, 2014 at 2:35 AM, Bert Freudenberg bert@freudenbergs.de wrote:
On 01.12.2014, at 07:35, Colin Putney colin@wiresong.com wrote:
On Sun, Nov 30, 2014 at 6:20 AM, Bert Freudenberg bert@freudenbergs.de wrote:
How would you define “type” here? Same class?
Yes, same class. It might be reasonable to answer instances of analogous classes for weak collections, and expect the caller to use #collect:as: if they want to retain weakness.
Colin
That’s certainly simple:
“collect: returns a collection of the same class as the receiver, except for weak collections, which answer non-weak equivalents. To return a collection of a different class, use collect:as:"
except collect: can't possibly do this for Interval. IMO, reify the idea of
Not only that, but the "except for weak collections" is a totally arbitrary exception, because the collected objects may or may not be referenced from elsewhere.
species in the comments for collect: and species and say that collect: answers something of the same species. The idea being that species is the same as class when the receiver is a mutable collection, but some other suitable class when it doesn't.