Issue 3426 in pharo: shouldBePrintedAsLiteral instead of isLiteral

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

Issue 3426 in pharo: shouldBePrintedAsLiteral instead of isLiteral

pharo
Status: Fixed
Owner: stephane.ducasse
Labels: Milestone-1.3

New issue 3426 by stephane.ducasse: shouldBePrintedAsLiteral instead of  
isLiteral
http://code.google.com/p/pharo/issues/detail?id=3426

Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.518.mcz

==================== Summary ====================

Name: Kernel-ul.518
Author: ul
Time: 23 November 2010, 1:54:49.317 pm
UUID: b098496d-94bb-f943-9cf9-bd07ab3b0b71
Ancestors: Kernel-dtl.517

- introduced Object >> #shouldBePrintedAsLiteral as a replacement for  
#isLiteral during printing and storing

=============== Diff against Kernel-dtl.517 ===============

Item was added:
+ ----- Method: Object>>shouldBePrintedAsLiteral (in category 'testing')  
-----
+ shouldBePrintedAsLiteral
+
+       ^self isLiteral!

Item was changed:
  ----- Method: ScaledDecimal>>storeOn: (in category 'printing') -----
  storeOn: aStream
        "SxaledDecimal sometimes have more digits than they print  
(potentially an infinity).
        In this case, do not use printOn: because it would loose some extra  
digits"

+       self shouldBePrintedAsLiteral
-       self isLiteral
                ifTrue: [self printOn: aStream]
                ifFalse: [aStream
                        nextPut: $(;
                        store: fraction numerator;
                        nextPut: $/;
                        store: fraction denominator;
                        nextPut: $s;
                        store: scale;
                        nextPut: $)]!



Reply | Threaded
Open this post in threaded view
|

Re: Issue 3426 in pharo: shouldBePrintedAsLiteral instead of isLiteral

pharo

Comment #1 on issue 3426 by stephane.ducasse: shouldBePrintedAsLiteral  
instead of isLiteral
http://code.google.com/p/pharo/issues/detail?id=3426

- use #shouldBePrintedAsLiteral instead of #isLiteral when printing or  
storing characters and arrays

=============== Diff against Collections-ul.410 ===============

Item was changed:
  ----- Method: Array>>printOn: (in category 'printing') -----
  printOn: aStream
+       self shouldBePrintedAsLiteral ifTrue: [^self printAsLiteralFormOn:  
aStream].
-       self isLiteral ifTrue: [^self printAsLiteralFormOn: aStream].
        self class = Array ifTrue: [^self printAsBraceFormOn: aStream].
        ^super printOn: aStream!

Item was added:
+ ----- Method: Array>>shouldBePrintedAsLiteral (in category 'testing')  
-----
+ shouldBePrintedAsLiteral
+
+       ^self class == Array and: [ self allSatisfy: [ :each | each  
shouldBePrintedAsLiteral ] ]!

Item was changed:
  ----- Method: Array>>storeOn: (in category 'printing') -----
  storeOn: aStream
        "Use the literal form if possible."

+       self shouldBePrintedAsLiteral
-       self isLiteral
                ifTrue:
                        [aStream nextPut: $#; nextPut: $(.
                        self do:
                                [:element |
                                element storeOn: aStream.
                                aStream space].
                        aStream nextPut: $)]
                ifFalse: [super storeOn: aStream]!

Item was changed:
  ----- Method: Array>>storeOnStream: (in category 'filter streaming') -----
  storeOnStream:aStream
+
+       self shouldBePrintedAsLiteral
+               ifTrue: [ super storeOnStream:aStream ]
+               ifFalse:[ aStream writeCollection:self ]
-       self isLiteral ifTrue: [super storeOnStream:aStream]  
ifFalse:[aStream writeCollection:self].
  !

Item was changed:
+ ----- Method: Character>>isLiteral (in category 'testing') -----
- ----- Method: Character>>isLiteral (in category 'printing') -----
  isLiteral

        ^true!

Item was added:
+ ----- Method: Character>>shouldBePrintedAsLiteral (in category 'testing')  
-----
+ shouldBePrintedAsLiteral
+
+       ^value between: 33 and: 255!

Item was changed:
  ----- Method: Character>>storeOn: (in category 'printing') -----
  storeOn: aStream
        "Common character literals are preceded by '$', however special need  
to be encoded differently: for some this might be done by using one of the  
shortcut constructor methods for the rest we have to create them by  
ascii-value."

        | name |
+       self shouldBePrintedAsLiteral
-       (value between: 33 and: 255)
                ifTrue: [ aStream nextPut: $$; nextPut: self ]
                ifFalse: [
                        name := self class constantNameFor: self.
                        name notNil
                                ifTrue: [ aStream nextPutAll: self class  
name; space; nextPutAll: name ]
                                ifFalse: [
                                        aStream
                                                nextPut: $(; nextPutAll:  
self class name;
                                                nextPutAll: ' value: ';  
print: value; nextPut: $) ] ].!


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3426 in pharo: shouldBePrintedAsLiteral instead of isLiteral

pharo

Comment #2 on issue 3426 by stephane.ducasse: shouldBePrintedAsLiteral  
instead of isLiteral
http://code.google.com/p/pharo/issues/detail?id=3426

I like this change.



Reply | Threaded
Open this post in threaded view
|

Re: Issue 3426 in pharo: shouldBePrintedAsLiteral instead of isLiteral

pharo
Updates:
        Status: FixProposed

Comment #3 on issue 3426 by [hidden email]: shouldBePrintedAsLiteral  
instead of isLiteral
http://code.google.com/p/pharo/issues/detail?id=3426

(No comment was entered for this change.)


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3426 in pharo: shouldBePrintedAsLiteral instead of isLiteral

pharo
Updates:
        Status: FixedWaitingToBePharoed
        Labels: -Milestone-1.3

Comment #4 on issue 3426 by [hidden email]: shouldBePrintedAsLiteral  
instead of isLiteral
http://code.google.com/p/pharo/issues/detail?id=3426

Next action: make a changeset or slice