On Sun, Jul 01, 2012 at 03:15:21AM -0400, John Cowan wrote: > Marc Feeley scripsit: > > > What is the rationale for digit-value ? Its usefullness seems limited. > > It could be used to parse decimal numbers and convert them to their > > numerical value. However, a more general procedure would be useful > > to parse numbers in any base: > > Its purpose is to determine for any digit character (not merely the > European digits 0-9) what its numeric value is. For example, > (digit-value #\x0663) => 3, because ٣ U+0663 is the Arabic-Indic digit 3.
In that case I'd expect the following to return the number 40: (let ((p (open-input-string (string #\x0663 #\x0ea6)))) (eval (read p) (scheme-report-environment 7))) I don't see these "special" numerics listed in the lexical syntax for numbers. This procedure seems to have been thrown in just for the heck of it, which creates inconsistencies like the one I just showed. One of the key aspects of Scheme is that it's internally consistent. I think the best course of action is to simply drop this procedure. Alternatively, change it to accept just the ASCII number characters, and possibly with Marc's suggestion of accepting digits in any base (and perhaps an optional second argument to specify which base we're working in). That would really be useful, since that could be used to implement very common char->number conversion and could even be used internally in string->number (at least conceptually). Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth _______________________________________________ Scheme-reports mailing list [email protected] http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
