Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use stream's nextPutAll: #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vonbecmann
Copy link

what do you think?

@vonbecmann
Copy link
Author

it works because reader implements do:

@svenvc
Copy link
Owner

svenvc commented Sep 26, 2022

That is very clever ;-)

Now, it depends on a particular implementation of #nextPutAll: (the one in Stream). Looking at all implementations, I see some which would probably fail.

On the other hand, in this case we only need what #streamContents: uses.

The question remains if this change would improve the clarity of this already simple code, or obscure it.

@vonbecmann
Copy link
Author

good question.
i debug the following example
(NeoCSVReader on: '"1",,"3"' readStream) upToEnd
and it depends on
WriteStream>>nextPutAll: and given the first stmt
collection class == aCollection class ifFalse: [^ super nextPutAll: aCollection ].
it goes to

Stream>>#nextPutAll: aCollection 
	"Append the elements of aCollection to the sequence of objects accessible 
	by the receiver. Answer aCollection."
	
	aCollection do: [:v | self nextPut: v].
	^aCollection

and then goes to WriteStream>>#nextPut:.
the message send is longer with more dependencies.
the previous version had one dependency WriteStream>>#nextPut:
in any case it always depends on WriteStream(Collections-Streams).

@vonbecmann
Copy link
Author

just showing off a clever hack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants