[Bug] #select:collect:
Brian Rice
water at tunes.org
Mon Feb 21 01:40:40 PST 2005
On Feb 20, 2005, at 5:20 PM, Daniel John Crowe wrote:
> when using #select:collect: on a Set i recieve a MNF error for
> #putNext:
It should be #nextPut: as described in stream.slate. If I run an
example as you describe, that's the selector that comes up in the debug
message, so I'll assume that you just didn't bother to copy directly
from the output. Anyway, this is a bug.
> I had a little look, but was unable to discover the intended protocol
> for writers. Adding #putNext: fixed the MNF but #select:collect:
> returned an Array. I would have expected a Set.
nextPut: is supposed to be defined on streams, not Sets or collections
themselves, so you basically messed up the whole logic for this. I
looked at the definition of select:collect:, and it seems that the
error is simple:
c@(Collection traits) select: test collect: block
"An optimization for staged collect:'s on select: results."
[| result |
result: c new writer.
c do: [| :each | (test applyWith: each)
ifTrue: [result nextPut: (block applyWith: each)]].
result contents
].
The "writer" part was missing, causing it to apply to the Set and not a
WriteStream on the Set. Also, #contents on a Stream retrieves what has
been written. #contents on a /Set/ returns the underlying Array, which
is why your confused method definition had the confusing result.
I've committed the fix to CVS.
--
Brian T. Rice
LOGOS Research and Development
http://tunes.org/~water/
More information about the Slate
mailing list