pharo icon indicating copy to clipboard operation
pharo copied to clipboard

Deprecate `Object >> #split:`?

Open jordanmontt opened this issue 1 year ago • 4 comments

The method Object >> #split is understood by all objects. The method's comment says

Split the argument using the receiver as a separator. Optimized version for single delimiters

The question is, does it make sense to have that method in Object? For example, if we do

SpPresenter new split: 'hello'` "'hello'"

It will return 'hello' which, for me, it does not make sense.

jordanmontt avatar Oct 01 '24 09:10 jordanmontt

We could move the code (switching receiver and argument) and have a #splitUsing: in SequenceableCollection,

'Hello' splitUsing: $l

We can use it in Object>>split: but deprecate this one.

split: aSequenceableCollection

  ^ aSequenceableCollection splitUsing: self

astares avatar Oct 01 '24 11:10 astares

Yes, we can have a splitUsing:. But, we will need to refactor SequenceableCollection>>#splitOn: to that does the same thing but inversely.

For Object >> #split: I'd say to remove it. Because the method is not clear. It should not be understood by all objects. The SpPresenter is a good example. Why a presenter understand split:

jordanmontt avatar Oct 01 '24 12:10 jordanmontt

Remove yes - but as there might be users we should deprecate it for at least one iteration. As usual.

astares avatar Oct 01 '24 15:10 astares

Yes, I meant to deprecate it to remove it in the next Pharo version

jordanmontt avatar Oct 01 '24 20:10 jordanmontt