On Wed, Mar 23, 2005 at 07:33:43PM +0100, Thomas Sandlaß wrote: : Larry Wall wrote: : >So we should probably : >have a generalized radix_to_dec($radix,$input) function out there : >somewhere instead. : : Why not shift it onto the type system: : : my Int $i = $input as Str[$radix] as Int; : : A bit lengthy but quite clear. : And easy to extend e.g. to roman numerals: : : say "VII" as Str[Roman] as Int; # prints 7
I'm not sure most people want to think that way. In fact, I'm slightly sure most people don't. : Of course then we need : : class Str[ uint $radix where { $radix > 1 } ] : {...} : class Str[ ::T does StringNumification ] : {...} And then, based only on what you've written there, we need to teach people all about classes, parameterized types, representational types, constraints, formal type parameters, and roles before they can begin to write the radix_to_dec() function they actually wanted... Larry