HI while working on a lecture I saw that we have about 75 cases like: aStream nextPut: $(. .... aStream nextPut: $). storeOn: aStream "Store a description of the elements of the complement rather than self." aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement. printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $) we have surroundedBy: aString surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ]. But only working on aString. To me it looks like it ia class for having it on stream. What do you think?
On 24 Jul 2015, at 22:48, stepharo <stepharo@free.fr> wrote:
HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
Iâm not sure about #surroundedBy:, but I would definitely vote for a nicer way of doing that, yes.
In BioSmalltalk I use this pattern a lot: aStream nextPutAll: self name between: $[ -> $]. so yes, that would be a nice inclusion for me :) Cheers, Hernán 2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>:
HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
(From my vacations) Doesn't this solves the problem? stream << $( << name << $) It is already there :) Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>:
HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
On 25 Jul 2015, at 19:40, Esteban Lorenzano <estebanlm@gmail.com> wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :)
Yes, indeed: String streamContents: [ :out | out <<$( << 'test-' << 123 << $) ] (But it is not perfect, there is still confusion there) We are trying to reduce the String and Stream API, so any addition should be really important/significant.
Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>: HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 25 Jul 2015, at 19:40, Esteban Lorenzano <estebanlm@gmail.com> wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :)
Yes, indeed:
String streamContents: [ :out | out <<$( << 'test-' << 123 << $) ]
(But it is not perfect, there is still confusion there)
I agree. Iâve never liked that operator. Apart from #// and #\\ there are pretty much no selectors that make you guess their meaning. The meaning is in all other cases transported through wording, which I feel very comfortable with. Yes, itâs convenient to write but, as Sven points out, I actually find it less readable. I like Hernanâs idea better.
We are trying to reduce the String and Stream API, so any addition should be really important/significant.
Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>: HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
I too believe current #<< is perfectible, but is (IMO) a good trade off. When Camillo introduced it, he was following current conventions outside smalltalk world... And as I said, it is probably not perfect but I find it a good start. I would not include a specific solution for a particular problem when there is a generic one that fits. Esteban, still on holidays
On 25 Jul 2015, at 22:02, Max Leske <maxleske@gmail.com> wrote:
On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 25 Jul 2015, at 19:40, Esteban Lorenzano <estebanlm@gmail.com> wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :)
Yes, indeed:
String streamContents: [ :out | out <<$( << 'test-' << 123 << $) ]
(But it is not perfect, there is still confusion there)
I agree. Iâve never liked that operator. Apart from #// and #\\ there are pretty much no selectors that make you guess their meaning. The meaning is in all other cases transported through wording, which I feel very comfortable with. Yes, itâs convenient to write but, as Sven points out, I actually find it less readable. I like Hernanâs idea better.
We are trying to reduce the String and Stream API, so any addition should be really important/significant.
Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>: HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
I like the solution of hernan better. I think that surrounding is a common pattern. Stef Le 25/7/15 22:02, Max Leske a écrit :
On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 25 Jul 2015, at 19:40, Esteban Lorenzano <estebanlm@gmail.com> wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :) Yes, indeed:
String streamContents: [ :out | out <<$( << 'test-' << 123 << $) ]
(But it is not perfect, there is still confusion there) I agree. Iâve never liked that operator. Apart from #// and #\\ there are pretty much no selectors that make you guess their meaning. The meaning is in all other cases transported through wording, which I feel very comfortable with. Yes, itâs convenient to write but, as Sven points out, I actually find it less readable. I like Hernanâs idea better.
We are trying to reduce the String and Stream API, so any addition should be really important/significant.
Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>: HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
I also like more the Hernán proposal but I would prefer something like stream nextPutAll: self name between: $( and: $) To avoid creating an association On Jul 26, 2015 12:23 PM, "stepharo" <stepharo@free.fr> wrote:
I like the solution of hernan better. I think that surrounding is a common pattern.
Stef
Le 25/7/15 22:02, Max Leske a écrit :
On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 25 Jul 2015, at 19:40, Esteban Lorenzano <estebanlm@gmail.com>
wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :)
Yes, indeed:
String streamContents: [ :out | out <<$( << 'test-' << 123 << $) ]
(But it is not perfect, there is still confusion there)
I agree. Iâve never liked that operator. Apart from #// and #\\ there are pretty much no selectors that make you guess their meaning. The meaning is in all other cases transported through wording, which I feel very comfortable with. Yes, itâs convenient to write but, as Sven points out, I actually find it less readable. I like Hernanâs idea better.
We are trying to reduce the String and Stream API, so any addition
should be really important/significant.
Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>: HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
Hi, Well, If there wouldn't be already a way to do it, I wouldn't care which one to take. But this is not the case: we are discussing the introduction of a new vocabulary when there is already another who is fulfilling the place. In that sense, the proposed method solves a problem who is actually not there. If we do not like #<<, then we should remove it from system, but please, let's not add a more limited method when we have a more generic one who does the job... I repeat: we are not discussing the introduction of one or another method, but the introduction of one who overlaps another who is already there. Cheers, Esteban Ps: I will be back next thursday... I can discuss more then...
On 26 Jul 2015, at 17:22, stepharo <stepharo@free.fr> wrote:
I like the solution of hernan better. I think that surrounding is a common pattern.
Stef
Le 25/7/15 22:02, Max Leske a écrit :
On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 25 Jul 2015, at 19:40, Esteban Lorenzano <estebanlm@gmail.com> wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :) Yes, indeed:
String streamContents: [ :out | out <<$( << 'test-' << 123 << $) ]
(But it is not perfect, there is still confusion there) I agree. Iâve never liked that operator. Apart from #// and #\\ there are pretty much no selectors that make you guess their meaning. The meaning is in all other cases transported through wording, which I feel very comfortable with. Yes, itâs convenient to write but, as Sven points out, I actually find it less readable. I like Hernanâs idea better.
We are trying to reduce the String and Stream API, so any addition should be really important/significant.
Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>: HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
+1 I am with Esteban, I see no real need to add this, since we try to minimise the Stream/String APIs. Also, I often add more that just a string between the parenthesis, I want to write to a stream myself, so I would need a block, and that would not be that nice.
On 26 Jul 2015, at 20:49, Esteban Lorenzano <estebanlm@gmail.com> wrote:
Hi,
Well, If there wouldn't be already a way to do it, I wouldn't care which one to take. But this is not the case: we are discussing the introduction of a new vocabulary when there is already another who is fulfilling the place. In that sense, the proposed method solves a problem who is actually not there. If we do not like #<<, then we should remove it from system, but please, let's not add a more limited method when we have a more generic one who does the job...
I repeat: we are not discussing the introduction of one or another method, but the introduction of one who overlaps another who is already there.
Cheers, Esteban
Ps: I will be back next thursday... I can discuss more then...
On 26 Jul 2015, at 17:22, stepharo <stepharo@free.fr> wrote:
I like the solution of hernan better. I think that surrounding is a common pattern.
Stef
Le 25/7/15 22:02, Max Leske a écrit :
On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 25 Jul 2015, at 19:40, Esteban Lorenzano <estebanlm@gmail.com> wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :) Yes, indeed:
String streamContents: [ :out | out <<$( << 'test-' << 123 << $) ]
(But it is not perfect, there is still confusion there) I agree. Iâve never liked that operator. Apart from #// and #\\ there are pretty much no selectors that make you guess their meaning. The meaning is in all other cases transported through wording, which I feel very comfortable with. Yes, itâs convenient to write but, as Sven points out, I actually find it less readable. I like Hernanâs idea better.
We are trying to reduce the String and Stream API, so any addition should be really important/significant.
Now I comeback to watch the see...
On 25 Jul 2015, at 18:39, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>: HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
2015-07-26 15:49 GMT-03:00 Esteban Lorenzano <estebanlm@gmail.com>:
Hi,
Well, If there wouldn't be already a way to do it, I wouldn't care which one to take. But this is not the case: we are discussing the introduction of a new vocabulary when there is already another who is fulfilling the place. In that sense, the proposed method solves a problem who is actually not there. If we do not like #<<, then we should remove it from system, but please, let's not add a more limited method when we have a more generic one who does the job...
<< is horrible, it reminds me to std::cout in C++ and all those cryptic languages where you cannot write a line without checking the API reference manual. Hernán
2015-07-27 8:26 GMT+02:00 Hernán Morales Durand <hernan.morales@gmail.com>:
2015-07-26 15:49 GMT-03:00 Esteban Lorenzano <estebanlm@gmail.com>:
Hi,
Well, If there wouldn't be already a way to do it, I wouldn't care which one to take. But this is not the case: we are discussing the introduction of a new vocabulary when there is already another who is fulfilling the place. In that sense, the proposed method solves a problem who is actually not there. If we do not like #<<, then we should remove it from system, but please, let's not add a more limited method when we have a more generic one who does the job...
<< is horrible, it reminds me to std::cout in C++ and all those cryptic languages where you cannot write a line without checking the API reference manual.
I like "<<" because it reminds me to std::cout in C++ :)
Hernán
2015-07-27 4:24 GMT-03:00 Nicolai Hess <nicolaihess@web.de>:
2015-07-27 8:26 GMT+02:00 Hernán Morales Durand <hernan.morales@gmail.com> :
2015-07-26 15:49 GMT-03:00 Esteban Lorenzano <estebanlm@gmail.com>:
Hi,
Well, If there wouldn't be already a way to do it, I wouldn't care which one to take. But this is not the case: we are discussing the introduction of a new vocabulary when there is already another who is fulfilling the place. In that sense, the proposed method solves a problem who is actually not there. If we do not like #<<, then we should remove it from system, but please, let's not add a more limited method when we have a more generic one who does the job...
<< is horrible, it reminds me to std::cout in C++ and all those cryptic languages where you cannot write a line without checking the API reference manual.
I like "<<" because it reminds me to std::cout in C++
:)
Maybe you're more comfortable in a C++ forum too ;) Seriously, I don't know, but whatever you choose please make it human inferrable from just by reading the selector name. Because << is arithmetic/bitwise operator for most coders in the world, and there are more developers to come and be newbies, than smalltalkers ever. Hernán
Esteban I'm confused. I know << and I use it. Now << is different to what I mentioned. The point is not to replace nextPutAll: by << I'm not that stupid. The point is the surrounding behavior (opening and closing). Sven of course there are more than a name so this is why I thought about stream surround: aBlock between: '( ' and: ' )' With << it means that we will have all the surrounding logic in all the code. Stef
stream surround: aBlock between: '( ' and: ' )'
This may be personal preference, but I do not like having more method arguments after a block argument... because if the block is longer it may not be visible... e.g. stream surround: [ :aStream | self size > 100 ifTrue: [ aStream nextPutAll: 'size '. self size printOn: aStream ] ifFalse: [ self keysSortedSafely do: [ :key | aStream print: key; nextPutAll: '->'; print: (self at: key); space ] ] ] between: $( and: $) vs between:and:surround: if you actually run this through formatter in Pharo, the between:and: is not even visible --- you have to scroll to see it. Of course if aBlock is a variable, than my argument falls.
From visual perspective the current state actually isn't that bad because you immediately see where is beginning and where is end without even looking... with surround:between:and: not so much...
Peter
Could be ok too. Le 27/7/15 09:53, Peter Uhnák a écrit :
stream surround: aBlock between: '( ' and: ' )'
This may be personal preference, but I do not like having more method arguments after a block argument... because if the block is longer it may not be visible... e.g.
stream surround: [ :aStream | self size > 100 ifTrue: [ aStream nextPutAll: 'size '. self size printOn: aStream ] ifFalse: [ self keysSortedSafely do: [ :key | aStream print: key; nextPutAll: '->'; print: (self at: key); space ] ] ] between: $( and: $)
vs between:and:surround:
if you actually run this through formatter in Pharo, the between:and: is not even visible --- you have to scroll to see it. Of course if aBlock is a variable, than my argument falls.
From visual perspective the current state actually isn't that bad because you immediately see where is beginning and where is end without even looking... with surround:between:and: not so much...
Peter
Le 27/7/15 09:53, Peter Uhnák a écrit :
stream surround: aBlock between: '( ' and: ' )'
This may be personal preference, but I do not like having more method arguments after a block argument... because if the block is longer it may not be visible...
+1
e.g.
stream surround: [ :aStream | self size > 100 ifTrue: [ aStream nextPutAll: 'size '. self size printOn: aStream ] ifFalse: [ self keysSortedSafely do: [ :key | aStream print: key; nextPutAll: '->'; print: (self at: key); space ] ] ] between: $( and: $)
vs between:and:surround:
That could even be #between:and:putAll: On Sat, Jul 25, 2015 at 4:48 AM, stepharo <stepharo@free.fr> wrote:
HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
... we have surroundedBy: aString
But only working on aString.
Well it seems that #surroundedBy: only has one sender #surroundedBySingleQuotes which in turn seems to be not sent anywhere. So actually #surroundedBy: seems ripe for culling to be replaced by more generic... aStream between: '(' and: ')' putAll: [ ... nextLevelIn ... ]. Now for most of those 75 cases and other cases where this pattern might apply, is performance so critical that using $( rather than '(' gains a lot? Perhaps on ancient machine and before Cog it was important but now using $( now is premature optimisation? Otherwise we might also need #betweenChars:and:putAll: On Mon, Jul 27, 2015 at 3:59 PM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
In most cases we always surround text by "()". Can we just provide method for this and not duplicate "between: '( ' and: ' )'" everywhere? Something like "stream>>printInBrackets:"
Maybe it is also a useful pattern for markup languages: aStream between: '<HEAD>' and: '</HEAD>' putAll: [ ... nextLevelIn ... ]. On Sun, Jul 26, 2015 at 1:40 AM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
(From my vacations)
Doesn't this solves the problem?
stream << $( << name << $)
It is already there :)
That is a reasonable point, but I think the having start and end tokens in visual close proximity has a slight advantage. On Mon, Jul 27, 2015 at 6:23 PM, stepharo <stepharo@free.fr> wrote:
May be I raised a not important issue.
Of course its easier to have an opinion on simple things. cheers -ben
is performance so critical that using $( rather than '('
gains a lot?
There's visual gain that I've mentioned. If you replace $( with '(' then my argument about visibility fails. $( is very distinct.
Maybe it is also a useful pattern for markup languages:
aStream between: '<HEAD>' and: '</HEAD>' putAll: [ ... nextLevelIn ... ].
I don't think it's a good practice to generate individual tags by hand, you should have more abstraction. Pillar has PRHTMLTag>>with: aString stream << $> << aString << '</' << name << $> Apart from it being hard to read due to </> it's so simple that it doesn't matter and you have little to no gain in trying to make it "nicer". Peter
Probably that the gain is not enough. This is just annoying to not have surrounding. Le 27/7/15 18:20, Peter Uhnák a écrit :
is performance so critical that using $( rather than '(' gains a lo
There's visual gain that I've mentioned. If you replace $( with '(' then my argument about visibility fails. $( is very distinct.
Maybe it is also a useful pattern for markup languages:
aStream between: '<HEAD>' and: '</HEAD>' putAll: [ ... nextLevelIn ... ].
I don't think it's a good practice to generate individual tags by hand, you should have more abstraction.
Pillar has
PRHTMLTag>>with: aString stream << $> << aString << '</' << name << $>
Apart from it being hard to read due to </> it's so simple that it doesn't matter and you have little to no gain in trying to make it "nicer".
Peter
On 27 Jul 2015, at 7:42 , stepharo <stepharo@free.fr> wrote:
Probably that the gain is not enough. This is just annoying to not have surrounding.
Le 27/7/15 18:20, Peter Uhnák a écrit :
is performance so critical that using $( rather than '(' gains a lo There's visual gain that I've mentioned. If you replace $( with '(' then my argument about visibility fails. $( is very distinct.
Maybe it is also a useful pattern for markup languages:
aStream between: '<HEAD>' and: '</HEAD>' putAll: [ ... nextLevelIn ... ].
I don't think it's a good practice to generate individual tags by hand, you should have more abstraction.
Pillar has
PRHTMLTag>>with: aString stream << $> << aString << '</' << name << $>
Apart from it being hard to read due to </> it's so simple that it doesn't matter and you have little to no gain in trying to make it "nicer".
Peter
Faced with a choice of using multiple nextPut: / nextPutAll:'s, and using a selector like surround:with:and:, or was that put:and:around:, or did it included between: somehow? I think I know which I'd end up writing every single time. Same reason I think a lot of the specialized collect:/select:'s out there is pure bloat in a base image, and better left defined to users who prefer it. Cheers, Henry
Apart from it being hard to read due to </> it's so simple that it doesn't matter and you have little to no gain in trying to make it "nicer".
Peter
Faced with a choice of using multiple nextPut: / nextPutAll:'s, and using a selector like surround:with:and:, or was that put:and:around:, or did it included between: somehow? I think I know which I'd end up writing every single time.
Same reason I think a lot of the specialized collect:/select:'s out there is pure bloat in a base image,
Can you give an example?
and better left defined to users who prefer it.
Cheers, Henry
May be I raised a not important issue. Stef Le 27/7/15 09:53, Peter Uhnák a écrit :
stream surround: aBlock between: '( ' and: ' )'
This may be personal preference, but I do not like having more method arguments after a block argument... because if the block is longer it may not be visible... e.g.
stream surround: [ :aStream | self size > 100 ifTrue: [ aStream nextPutAll: 'size '. self size printOn: aStream ] ifFalse: [ self keysSortedSafely do: [ :key | aStream print: key; nextPutAll: '->'; print: (self at: key); space ] ] ] between: $( and: $)
vs between:and:surround:
if you actually run this through formatter in Pharo, the between:and: is not even visible --- you have to scroll to see it. Of course if aBlock is a variable, than my argument falls.
From visual perspective the current state actually isn't that bad because you immediately see where is beginning and where is end without even looking... with surround:between:and: not so much...
Peter
On 27 July 2015 at 12:23, stepharo <stepharo@free.fr> wrote:
May be I raised a not important issue.
My impression too. :)
Stef
Le 27/7/15 09:53, Peter Uhnák a écrit :
stream surround: aBlock between: '( ' and: ' )'
This may be personal preference, but I do not like having more method arguments after a block argument... because if the block is longer it may not be visible... e.g.
stream surround: [ :aStream | self size > 100 ifTrue: [ aStream nextPutAll: 'size '. self size printOn: aStream ] ifFalse: [ self keysSortedSafely do: [ :key | aStream print: key; nextPutAll: '->'; print: (self at: key); space ] ] ] between: $( and: $)
vs between:and:surround:
if you actually run this through formatter in Pharo, the between:and: is not even visible --- you have to scroll to see it. Of course if aBlock is a variable, than my argument falls.
From visual perspective the current state actually isn't that bad because you immediately see where is beginning and where is end without even looking... with surround:between:and: not so much...
Peter
-- Best regards, Igor Stasenko.
We all want to escape from routine, tedious and repeatable tasks.. But unfortunately there is some of them when it is going to stay no matter how you want to optimize, and implementing printing is one of good examples of such tasks. Adding 'convenience' methods won't help.. it will just balkanize new printing stuff from one that lies there for years. In thousands of projects.. because it is one of the central necessities, to see what your objects contain or to report something somewhere in readable form, and that involves *drumroll* printing :) On 27 July 2015 at 15:15, Igor Stasenko <siguctua@gmail.com> wrote:
On 27 July 2015 at 12:23, stepharo <stepharo@free.fr> wrote:
May be I raised a not important issue.
My impression too. :)
Stef
Le 27/7/15 09:53, Peter Uhnák a écrit :
stream surround: aBlock between: '( ' and: ' )'
This may be personal preference, but I do not like having more method arguments after a block argument... because if the block is longer it may not be visible... e.g.
stream surround: [ :aStream | self size > 100 ifTrue: [ aStream nextPutAll: 'size '. self size printOn: aStream ] ifFalse: [ self keysSortedSafely do: [ :key | aStream print: key; nextPutAll: '->'; print: (self at: key); space ] ] ] between: $( and: $)
vs between:and:surround:
if you actually run this through formatter in Pharo, the between:and: is not even visible --- you have to scroll to see it. Of course if aBlock is a variable, than my argument falls.
From visual perspective the current state actually isn't that bad because you immediately see where is beginning and where is end without even looking... with surround:between:and: not so much...
Peter
-- Best regards, Igor Stasenko.
-- Best regards, Igor Stasenko.
Hi. In most cases we always surround text by "()". Can we just provide method for this and not duplicate "between: '( ' and: ' )'" everywhere? Something like "stream>>printInBrackets:" 2015-07-27 10:33 GMT+03:00 stepharo <stepharo@free.fr>:
Esteban
I'm confused. I know << and I use it. Now << is different to what I mentioned. The point is not to replace nextPutAll: by << I'm not that stupid.
The point is the surrounding behavior (opening and closing). Sven of course there are more than a name so this is why I thought about
stream surround: aBlock between: '( ' and: ' )'
With << it means that we will have all the surrounding logic in all the code.
Stef
I'm seeing that all causes of "output between brackets" are located in printString/printOn: methods Perhaps, it will be better to create special method like nextPutAllWithClassName: or something like it? 27/07/15 10:59, Denis Kudriashov пиÑеÑ:
Hi.
In most cases we always surround text by "()". Can we just provide method for this and not duplicate "between: '( ' and: ' )'" everywhere? Something like "stream>>printInBrackets:"
2015-07-27 10:33 GMT+03:00 stepharo <stepharo@free.fr <mailto:stepharo@free.fr>>:
Esteban
I'm confused. I know << and I use it. Now << is different to what I mentioned. The point is not to replace nextPutAll: by << I'm not that stupid.
The point is the surrounding behavior (opening and closing). Sven of course there are more than a name so this is why I thought about
stream surround: aBlock between: '( ' and: ' )'
With << it means that we will have all the surrounding logic in all the code.
Stef
On Sat, Jul 25, 2015 at 9:39 AM, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
i don't like the allocation here; v slow. why not nextPutAll:between:and: ?
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>:
HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
-- _,,,^..^,,,_ best, Eliot
2015-07-29 20:09 GMT-03:00 Eliot Miranda <eliot.miranda@gmail.com>:
On Sat, Jul 25, 2015 at 9:39 AM, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
i don't like the allocation here; v slow. why not nextPutAll:between:and: ?
Because I wasn't very inspired :) Thanks! Hernán
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>:
HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
-- _,,,^..^,,,_ best, Eliot
On 7/29/15, Eliot Miranda <eliot.miranda@gmail.com> wrote:
On Sat, Jul 25, 2015 at 9:39 AM, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
In BioSmalltalk I use this pattern a lot:
aStream nextPutAll: self name between: $[ -> $].
so yes, that would be a nice inclusion for me :)
i don't like the allocation here; v slow. why not nextPutAll:between:and: ?
+1
Cheers,
Hernán
2015-07-24 17:48 GMT-03:00 stepharo <stepharo@free.fr>:
HI
while working on a lecture I saw that we have about 75 cases like:
aStream nextPut: $(. .... aStream nextPut: $).
storeOn: aStream "Store a description of the elements of the complement rather than self."
aStream nextPut: $(. absent storeOn: aStream. aStream nextPut: $); space; nextPutAll: #complement.
printElementsOn: aStream aStream nextPut: $(. self size > 100 ifTrue: [aStream nextPutAll: 'size '. self size printOn: aStream] ifFalse: [self keysSortedSafely do: [:key | aStream print: key; nextPutAll: '->'; print: (self at: key); space]]. aStream nextPut: $)
we have surroundedBy: aString
surroundedBy: aString ^ self class streamContents: [ :s| s nextPutAll: aString. s nextPutAll: self. s nextPutAll: aString ].
But only working on aString. To me it looks like it ia class for having it on stream.
What do you think?
-- _,,,^..^,,,_ best, Eliot
participants (15)
-
Ben Coman -
Denis Kudriashov -
Eliot Miranda -
Esteban Lorenzano -
Gabriel Cotelli -
H. Hirzel -
Henrik Johansen -
Hernán Morales Durand -
Igor Stasenko -
Max Leske -
Nicolai Hess -
Peter Uhnák -
stepharo -
Sven Van Caekenberghe -
Vladimir Musulainen