Kudos Fabio for noticing the non-symmetry in type coercion between Strings and Characters. I was doing a little more research and noticed we have all these adapt'ing methods on *Object* (!!).
Object>>#adaptToFloat:andCompare: Object>>#adaptToFloat:andSend: Object>>#adaptToFraction:andCompare: Object>>#adaptToFraction:andSend: Object>>#adaptToInteger:andCompare: Object>>#adaptToInteger:andSend: Object>>#adaptToScaledDecimal:andCompare:
Browse origin showed methods added in 2006 by Kernel-nice.398 (version notes below). The explanation given there and in all three Mantis reports relates to coercions between Integers and Floats.
So, it doesn't appear that these were intended to encourage automatic coercion of ANY object to the numbers domain for interoperation with numbers, but its presence on Object maybe was the common superclass for the implementation.
I submitted an alternative version to the Inbox which proposes symmetry between Strings and Characters to be that they both require explicit coercion.
Whether to do automatic coercion in the language feels like a weighty decision. My gut is telling me its better to be conservative in doing auto coercing, but I'm sure Nicolas' and others' can better articulate an the most intelligent path forward.
- Chris
_____________ Name: Kernel-nice.398 Author: nice Time: 13 February 2010, 4:31:00.389 am UUID: f1525362-d01a-214c-94fe-2bb3a5fffa89 Ancestors: Kernel-nice.397
Fix http://bugs.squeak.org/view.php?id=3360 http://bugs.squeak.org/view.php?id=3374 http://bugs.squeak.org/view.php?id=6601
hash and = are now reconciled for numbers. = is now transitive for numbers.
WARNING: now, tests like (1/10 = 0.1) will answer false. This is expected, and more than expected, this is wanted. Float are inexact and testing for strict equality is not a clever thing to do. All this has been longly debated at http://permalink.gmane.org/gmane.comp.lang.smalltalk.pharo.devel/10642 http://thread.gmane.org/gmane.comp.lang.smalltalk.sapphire.devel/10223/focus...
Please, read carefully this thread to make an opinion before raising your voice. It can break code eventually, so I'm all ears to real case, and willing to help fixing. But please, real examples, not theoretical (after 8 month change in Pharo, I'm not aware of further complaints).