About nextPutAll: $(

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|

About nextPutAll: $(

stepharo
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?




Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Max Leske

> On 24 Jul 2015, at 22:48, stepharo <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

hernanmd
In reply to this post by stepharo
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 <[hidden email]>:
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?





Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

EstebanLM
(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 <[hidden email]> 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 <[hidden email]>:
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?





Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Sven Van Caekenberghe-2

> On 25 Jul 2015, at 19:40, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>:
>> 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?
>>
>>
>>
>>
>>


Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Max Leske

> On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <[hidden email]> wrote:
>
>
>> On 25 Jul 2015, at 19:40, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>:
>>> 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?
>>>
>>>
>>>
>>>
>>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

EstebanLM
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 <[hidden email]> wrote:
>
>
>> On 25 Jul 2015, at 21:31, Sven Van Caekenberghe <[hidden email]> wrote:
>>
>>
>>> On 25 Jul 2015, at 19:40, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>:
>>>> 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?
>
>

Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

stepharo
In reply to this post by Max Leske
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 <[hidden email]> wrote:
>>
>>
>>> On 25 Jul 2015, at 19:40, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>:
>>>> 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?
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

gcotelli

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" <[hidden email]> 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 <[hidden email]> wrote:


On 25 Jul 2015, at 19:40, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>:
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?










Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

EstebanLM
In reply to this post by stepharo
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 <[hidden email]> 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 <[hidden email]> wrote:
>>>
>>>
>>>> On 25 Jul 2015, at 19:40, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>:
>>>>> 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?
>
>

Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Sven Van Caekenberghe-2
+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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> wrote:
>>>>
>>>>
>>>>> On 25 Jul 2015, at 19:40, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>:
>>>>>> 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?
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

hernanmd
In reply to this post by EstebanLM

2015-07-26 15:49 GMT-03:00 Esteban Lorenzano <[hidden email]>:
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

Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Nicolai Hess


2015-07-27 8:26 GMT+02:00 Hernán Morales Durand <[hidden email]>:

2015-07-26 15:49 GMT-03:00 Esteban Lorenzano <[hidden email]>:
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


Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

stepharo
In reply to this post by EstebanLM
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

Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Peter Uhnak

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
Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Denis Kudriashov
In reply to this post by stepharo
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 <[hidden email]>:
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


Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

hernanmd
In reply to this post by Nicolai Hess


2015-07-27 4:24 GMT-03:00 Nicolai Hess <[hidden email]>:


2015-07-27 8:26 GMT+02:00 Hernán Morales Durand <[hidden email]>:

2015-07-26 15:49 GMT-03:00 Esteban Lorenzano <[hidden email]>:
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
 

Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

stepharo
In reply to this post by Peter Uhnak
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

Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

stepharo
In reply to this post by Peter Uhnak
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

Reply | Threaded
Open this post in threaded view
|

Re: About nextPutAll: $(

Igor Stasenko


On 27 July 2015 at 12:23, stepharo <[hidden email]> 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.
12