Nicolas, Silent failures are **BAD**. I always like to compare things to #at: and #at:ifAbsent:. #at: will answer the indicated item or raise an exception. #at:ifAbsent: allows one to customize the behavior and w/o the expense of setting up an exception handler, which is great if the error (bounds in this case) can be understood and corrected locally. Of course, structured exceptions arose to handle the common situation in which I find an error but only you can tell what to do about it, and we are working on completely different parts of the system.
This whole debate arises again with end-of-stream exceptions: http://code.google.com/p/pharo/wiki/StreamsForRobustSoftware I am using the additional protocol approach with good results, but should try to make some time to test your pluggable exception idea. Bill -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Nicolas Cellier Sent: Thursday, September 24, 2009 3:19 AM To: [email protected] Subject: Re: [Pharo-project] '.2e2' asNumber ? The two problems were identified from the beginning: 1) 2.e5 and .2 did work in old squeak images, but no more with SqNumberParser Rationale: SqNumberParser is for parsing number literals in squeak syntax, and those extensions are not identified squeak syntax If you need these syntax, the best thing is to subclass the NumberParser. For example, I must have a FORTRANNumberParser available somewhere... 2) Silently returning zero in case of error. This was one of the goal of SqNumberParser: let programmer choose the appropriate behaviour - raise an Exception - answer nil - answer a default value (zero) The last solution has been connected to Number class>>#readFrom: for historical compatibility reasons. I agree this conservative choice was unfortunate. Pharo should not fear and break compatibility on such dumb behaviours. Nicolas 2009/9/24 Stéphane Ducasse <[email protected]>: > I imagine that nicolas will let us know. > If you have tests we would love to integrate them so that we can > detect that. > > Stef > > On Sep 23, 2009, at 11:25 PM, John M McIntosh wrote: > >> I noticed that in Squeak and earlier version of Pharo doing '.2e2' >> asNumber would return 20.0 or '.2' asNumber would return 0.2 >> >> but currently in Pharo those return 0, without error, comment, or >> other hand waving. >> Good thing I have Sunits... >> >> So is this a bug or feature? >> >> Hint obviously in the Fractions calculator people are lazy and enter . >> 2e2 or .2 without the leading zero... >> >> -- >> = >> = >> = >> = >> = >> ===================================================================== >> = John M. McIntosh <[email protected]> Twitter: >> squeaker68882 >> Corporate Smalltalk Consulting Ltd. http:// >> www.smalltalkconsulting.com = = = = = >> ===================================================================== >> = >> >> >> >> >> >> _______________________________________________ >> Pharo-project mailing list >> [email protected] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [email protected] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
