On Sun, 19 Feb 2017 16:04:31 +0100, stepharong <stepharong@free.fr> wrote:

Hi doru

Yes I know. I did not imply anything. 
I think that the current status is bogus.
I do not see any scenario that makes printString not returning and displaying a string good.

Yes there is one: the self evaluating objects

1 printIt
>>> 1

true printIt
>>> true

true printString printIt
>>> 'true'

now I'm confused because there is something that does not work.




I do not get why
'comics' printString should double quote it.
to me

'comics' printString
>>>
'comics'


'comics' printIt
>>> 
'comics'

as well as 

(#AAA asClass new name: 'comics') PrintIt


I just to not get what is the benefit not to have in the workspace or any users of printIt no single quote


I agree that for a list of items
you do not want to have 

     'astroboy' 
     'tintin'

but instead 
      astroboy
      tintin

I see that lot of people got confused about that. Just look at the cuboid videos of Roassal you get comboboxes full of ' ' while there should not have any. 

Now to me this is the job of displayString. 

displayString is not the same as printString. 

printString should return a string and I should see a string in the REPL

Currently in the REPL because this is what we are talking about 
obtaining a non string is confusing. 

Am I clear?
Stef

Hi Stef,

Just a clarification. I do not argue here. I just explain what I see. I think it was like this since a long time. I even checked in an old VW I have around and it seems to have the same behavior.

But, I do agree that it is not straightforward at all. It took me a while to figure this out and it is still confusing sometimes. In fact, this is why we have a String presentation in the String object - I needed something that clarifies situations like these. That does not mean it is the best solution :).


On Feb 19, 2017, at 11:42 AM, stepharong <stepharong@free.fr> wrote:

On Sun, 19 Feb 2017 11:40:04 +0100, Sven Van Caekenberghe <sven@stfx.eu> wrote:

Ah, you're right: there is a difference between printing a textual representation on a stream / window and doing the same with the actual (print)string. I was not yet fully awake I guess.

So 
'comics'
>>> comics  whatever it means
but
(#AAA asClass new name: 'comics')
>>> ���comics'

It���s the other way around :).

Example A:
'comics'
>>print it>> ���comics��� 
In this case we have a string object and we send printString to it which in String>>storeOn: adds the quotes as part of the contents of the new string.

Example B:
(#AAA asClass new name: 'comics')
>>print it>> comics 
Here we have an non-string object and we sent printString to it which creates a string with the contents of the stream. As no String>>storeOn: is invoked in this case, there are no quotes.

So, the two resulting print it strings do not have the same contents.

Maybe another case:

Example C:
(#AAA asClass new name: 'comics���) printString
>>print it>> ���comics���
This is equivalent to Example A. We send printString to a string object and we get the quotes.

The issue is that when we send printString to a string, we produce a new string with escaped quotes:
'comics' = (String streamContents: [:s | s << 'comics���]) contents. "true"
'comics' = (String streamContents: [:s | s << 'comics']) contents printString. "false"


I'm sorry but I do not get it at all.
Especially since we always wrote that printIt is sending printString.
I find that totally broken and I do not understand why this is good.

Another thing to keep in mind is:

Example D:
Object new
>>print it>> an Object
This is essentially equivalent with Example A

If Example B would produce 
>>print it>> ���comics���
it would mean that Example D would produce
>>print it>> ���an Object���

Ugh, I already got dizzy with so many quotes :).

One problem is that when you look at a string, you do not know how many String>>storeOn: commands it went through. So, here is an idea: what if String>>printString would produce a EscapedString, which behaves like an operator? In this case, we would see better how many levels of String>>storeOn: are being displayed.

What do you think?

Cheers,
Doru


Stef





On 19 Feb 2017, at 10:59, Tudor Girba <tudor@tudorgirba.com> wrote:

Hi,

Hmm, I think I do not see it :).

Let���s take it slowly. From what I see, the behavior is the same since at least Pharo 3.

Here is a script that seems to reproduce your situation:

Object subclass: #AAA
instanceVariableNames: 'name'
classVariableNames: ''
package: 'AAA'.
#AAA asClass compile: 'printOn: aStream
   aStream << name'.
#AAA asClass compile: 'name: aString
name := aString'.
#AAA asClass new name: 'comics'

In Pharo 6, we have in a Playground:

<Screen Shot 2017-02-19 at 10.48.55 AM.png>

In Pharo 3, we have this in a Workspace:

<Screen Shot 2017-02-19 at 10.49.26 AM.png>

Calling Print It on an object produces a string out of the contents of the stream, and displaying it shows the contents of the stream (so, no quotes). Calling Print It on a string produces a string of the string, and displaying it shows the quotes of the first string.

You can see this in the String tab of the inspector:

<p1.png>


<p2.png>

Does this make sense?

I think this is not inconsistent, but maybe there is a better way. In any case, the behavior seems to exist since a long time.

Cheers,
Doru


On Feb 19, 2017, at 9:06 AM, stepharong <stepharong@free.fr> wrote:

Hi doru

may be I do not see the obvious.
I defined a class

Object subclass: #MFElement
   instanceVariableNames: 'name parent'
   classVariableNames: ''
   package: 'MyFS2'

printOn: aStream
   parent isNil ifFalse: [ parent printOn: aStream ].
   aStream << name

name: aString
    name := aString


MFDirectory new name: 'comics'.


And when I do


(MFDirectory new name: 'comics')
comics/


(MFDirectory new name: 'comics') printString
'comics/'


Hi Stef,

I think I do not understand the issue.

Here is the screenshot of a Playground.

���comics��� -> print-it -> ���comics'

<Mail Attachment.png>

What am I missing?

Cheers,
Doru


On Feb 18, 2017, at 6:26 PM, stepharong <stepharong@free.fr> wrote:


Hi guys

I'm working on an introduction chapter for my future book and I do not like the behavior I see in latest pharo 60.

And I do not understand the behavior of print-it

(MFDirectory new name: 'comics')
comics/


(MFDirectory new name: 'comics') printString
'comics/'


Why print it does not produce ''?


Stef


printIt
"Treat the current text selection as an expression; evaluate it. Insert the
description of the result of evaluation after the selection and then make
this description the new text selection."

| printString |
self
evaluateSelectionAndDo: [ :result |
printString := [ result printString ]
on: Error
do: [ '<error in printString: try ''Inspect it'' to debug>' ].
self afterSelectionInsertAndSelect: printString ]




--
Using Opera's mail client: http://www.opera.com/mail/


--
www.tudorgirba.com
www.feenk.com

"It's not how it is, it is how we see it."




--
Using Opera's mail client: http://www.opera.com/mail/
<MFElement.st>

--
www.tudorgirba.com
www.feenk.com

"Problem solving should be focused on describing
the problem in a way that makes the solution obvious."








-- 
Using Opera's mail client: http://www.opera.com/mail/

--
www.tudorgirba.com
www.feenk.com

"From an abstract enough point of view, any two things are similar."







--
Using Opera's mail client: http://www.opera.com/mail/



--
Using Opera's mail client: http://www.opera.com/mail/