[Pharo-dev] confused about printString and printIt

Sven Van Caekenberghe sven at stfx.eu
Sun Feb 19 04:20:55 EST 2017


Stef is right, there is something strange. Consider the following 4 expressions, each time with the result of 'Print It' inserted:

#foo->'foo'. "#foo->'foo'"
(#foo->'foo') printString. "'#foo->''foo'''"

'foo'. "'foo'"
'foo' printString. "'''foo'''"

In a Workspace (not Playground), the following happens:

#foo->'foo'. #foo->'foo'
#foo->'foo' printString. #foo->'''foo'''

Which makes even less sense.

> On 19 Feb 2017, at 09:06, stepharong <stepharong at 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 at 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>




More information about the Pharo-dev mailing list