4 additions to core?

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

4 additions to core?

Hannes Hirzel
Hello Juan

As from the porting effort for NeoCSV I propose the following
additions for discussion to add to the core.

All methods are from Pharo 4.0

See attachment.


Regards

Hannes




'From Cuis 4.2 of 25 July 2013 [latest update: #2243] on 9 May 2015 at
7:17:46.231872 pm'!

!String methodsFor: 'copying' stamp: 'hjh 5/9/2015 16:32'!
join: aCollection
        "'*' join: #('WWWWW' 'W  EW' 'zzzz')
                ->  'WWWWW*W  EW*zzzz' "

        | w |
        w := WriteStream on: String new.
        aCollection do: [ :elem | w nextPutAll: elem asString] separatedBy:
[w nextPutAll: self].
        ^String fromString: w contents! !

!String methodsFor: 'formatting' stamp: 'hjh 5/9/2015 17:03'!
withCRs
        "Return a copy of the receiver in which backslash (\) characters have
been replaced with carriage returns."

        ^ self collect: [ :c | c = $\ ifTrue: [ Character cr ] ifFalse: [ c ]].! !


!Symbol methodsFor: 'private' stamp: 'hjh 5/9/2015 17:37'!
value: anObject
        ^anObject perform: self.! !


!Character methodsFor: 'testing' stamp: 'hjh 5/9/2015 17:11'!
isCharacter

        ^ true.! !

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

2244-CuisCore-HannesHirzel-2015May04-06h01m-hjh.1.cs.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 4 additions to core?

Juan Vuletich-4
Hi Hannes,

I added #join: to Cuis base.

But I added the others to package SqueakCompatibility.pck.st. Reasons are:

- String >> withCRs
Most times, what we really want is #withNewlines. But sometimes #withCRs is what's really needed. It depends on each case, and the package porter needs to decide. Having #withCRs in the base image would make it look like it is an "usual" Cuis method.

- Symbol >> value:
In Cuis, Symbol is not generally polymorphic with blocks. Changing that would be a decision to make. And to be consistent, we'd also support  stuff like 'aCollection collect: #printString'. I'm not sure I like that style, and in any case, it is not to be done without some discussion.

- Character >> isCharacter
I guess we'd also need to add it to Object for this to make sense. But we all agree that calling isXXX methods is not nice style, right?

WRT $b digitValue, in Cuis 16rB is valid, and 16rb is not. Letters as digits must be uppercase. This makes things like 10r1.2e3 unambiguous. Supporting lowercase digits would require some discussion. Is there any real need for this?

WRT #assert:description: , I added it to Cuis base. Sounds nice to have. I also adapted TestCase>>assert:description: to accept a block.

When the new updates are on github (hopefully later today), please load SqueakCompatibility.pck.st, and check if I missed something.

Thanks!
Juan Vuletich


On 5/9/2015 4:21 PM, H. Hirzel wrote:
Hello Juan

As from the porting effort for NeoCSV I propose the following
additions for discussion to add to the core.

All methods are from Pharo 4.0

See attachment.


Regards

Hannes




'From Cuis 4.2 of 25 July 2013 [latest update: #2243] on 9 May 2015 at
7:17:46.231872 pm'!

!String methodsFor: 'copying' stamp: 'hjh 5/9/2015 16:32'!
join: aCollection
	"'*' join: #('WWWWW' 'W  EW' 'zzzz')
		->  'WWWWW*W  EW*zzzz' "

	| w |		
	w := WriteStream on: String new.
	aCollection do: [ :elem | w nextPutAll: elem asString] separatedBy:
[w nextPutAll: self].
	^String fromString: w contents! !

!String methodsFor: 'formatting' stamp: 'hjh 5/9/2015 17:03'!
withCRs
	"Return a copy of the receiver in which backslash (\) characters have
been replaced with carriage returns."

	^ self collect: [ :c | c = $\ ifTrue: [ Character cr ] ifFalse: [ c ]].! !


!Symbol methodsFor: 'private' stamp: 'hjh 5/9/2015 17:37'!
value: anObject
	^anObject perform: self.! !


!Character methodsFor: 'testing' stamp: 'hjh 5/9/2015 17:11'!
isCharacter

	^ true.! !
_______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
dsg
Reply | Threaded
Open this post in threaded view
|

Re: 4 additions to core?

dsg
I agree with this. :)  A while back I noticed that some collections have isXXX (like isArray and isHeap), while others don't.  Is this just a matter of cleanup or is there some logic I'm missing?

On 5/10/2015 1:31 PM, Juan Vuletich wrote:


- Character >> isCharacter
I guess we'd also need to add it to Object for this to make sense. But we all agree that calling isXXX methods is not nice style, right?



_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: 4 additions to core?

Juan Vuletich-4
There's always more cleanup to be done!

#isHeap is easy to remove. But #isArray might be a bit riskier. These isXXX methods that simply answer a constant are extremely fast, and never cause context switch. I guess this is important for #isFloat, #isInteger, #isFraction, although the default that answers false could be defined in Number, and not Object... And I'm not really sure for #isArray.

As usual, if you feel like digging into this, contributions are welcome.

Cheers,
Juan Vuletich

On 5/12/2015 12:18 PM, David Graham wrote:
I agree with this. :)  A while back I noticed that some collections have isXXX (like isArray and isHeap), while others don't.  Is this just a matter of cleanup or is there some logic I'm missing?

On 5/10/2015 1:31 PM, Juan Vuletich wrote:


- Character >> isCharacter
I guess we'd also need to add it to Object for this to make sense. But we all agree that calling isXXX methods is not nice style, right?


_______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org