On 6/7/2010 12:17 PM, Niko Schwarz wrote:
Well, I'm just arguing that in Ruby, the simple convention that
negative indices start from left to right map to a zoo of different
methods in Smalltalk.

You didn't comment on:

('hello' from: 2 toFromEnd: 2) should = 'ell'

Would that find your blessing?

niko

What's the goal, to be more like Ruby? If that's the case I'm sure there's a thousand things you could change, but it's not Ruby, it's Smalltalk. Ruby seems to have a style where you can send just about anything to a method and it tries to figure out what to do based on the type of the arg, they like magic and the smaller API; Smalltalk tends to just have a dozen different but similarly named methods that let you accomplish the same thing. I prefer that latter style, less magic and more smaller simpler well factored methods with a larger API and less implicit assumptions.

Personally, I don't like a lot of unspoken assumptions like negative indices meaning something that isn't stated in the method name, so yes I like...

('hello' from: 2 toFromEnd: 2) should = 'ell'

better than using negative indices. Not sure I like #from:toFromEnd: as the selector name, but I like the spirit of it, it makes it explicit. I'd probably like #copyFrom:fromEnd: better, but that's just personal preference as it goes better with #copyFrom:to: which would seem to be a related method in that protocol.

I really don't want to learn 10 different ways to use #at:, I'd rather see 10 similarly named methods each doing it one way that look like they're all variations of a theme. When someone comes up with a new idea like #copyFrom:fromEnd:, it's easier to add that than it is to go back and patch #at: to do something new, it allows the system to grow over time yet remain stable for existing code.

--
Ramon Leon
http://onsmalltalk.com

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to