[squeak-dev] Character>to: was changed and breaks ObjectsTool

tim Rowledge tim at rowledge.org
Thu Jul 18 17:35:43 UTC 2013


On 18-07-2013, at 3:47 AM, Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com> wrote:
> I did the change and the rationale is that the most logical Collection recipient for Character is String, what else?

I'm not at all sure I agree there; yes, as mentioned before a String is a collection of Characters in some sense - but one should also consider an Interval as an Array that is specified by shorthand that relies on a known ordering. If we wrote
(Array with: $a with: $b with: $c) select:[:c| c =$b]
should we get #($b) or 'b' ? I think #($b) is correct.

> OrderedCollection is totally arbitrary with this respect. 
> OK, you cannot add: to a String. But can you add: to (1 to: 10)? No you can't.

That's why #species is there - to provide a suitable recipient for the results of enumerations when running over such objects.

> So, put together, the Rationale is simply a principle of least astonishment.

The practical problem is that even though I'm sure you looked to see what problems the change might cause  - because you're nice (how often do I get to make a fun pun on someone's name?) - you can't easily be sure that you can even see all the places where it might be troublesome. It broke a relatively basic tool that I stumbled upon because it is mentioned in a tutorial. How can we feel sure it doesn't affect other bits of code? I don't think it's terribly practical to search out every use of #to: (or other Interval creation methods) and then dig around to find out how it got used subsequently, it's simply too common an idiom. Within one's own special code it can still be tricky if the project has grown large (ask me about grokking Scratch…) but in the general case? Forget it, unless somebody has a project to really, truly automate it. And in all the cases where we didn't catch the problem, somebody is going to be unpleasantly astonished.

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
No, I don't explode cats. It's way too difficult to coax them into the microwave - http://tinyurl.com/yp3hgr



More information about the Squeak-dev mailing list