Discussion:
[Pharo-project] Issue 3426 in pharo: shouldBePrintedAsLiteral instead of isLiteral
pharo
2010-12-14 11:54:15 UTC
Permalink
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: $)]!
pharo
2010-12-14 11:58:16 UTC
Permalink
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: $) ] ].!
pharo
2010-12-30 21:37:09 UTC
Permalink
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.
pharo
2011-03-14 17:56:48 UTC
Permalink
Updates:
Status: FixProposed

Comment #3 on issue 3426 by marcus.d... at gmail.com: shouldBePrintedAsLiteral
instead of isLiteral
http://code.google.com/p/pharo/issues/detail?id=3426

(No comment was entered for this change.)
pharo
2011-03-18 20:31:08 UTC
Permalink
Updates:
Status: FixedWaitingToBePharoed
Labels: -Milestone-1.3

Comment #4 on issue 3426 by marcus.d... at gmail.com: shouldBePrintedAsLiteral
instead of isLiteral
http://code.google.com/p/pharo/issues/detail?id=3426

Next action: make a changeset or slice

Loading...