develooper Front page | perl.perl6.language | Postings from October 2001


Thread Previous | Thread Next
David Nicol
October 12, 2001 16:31
Message ID:
Jonathan Scott Duff wrote:

> I'll agree as long as we make the string "1e2foo" evaluate to 1 in a
> numeric context rather than 100 (as it does in perl 5 now). 

Ouch.  I wonder what mysterious problems that is causing.

Hmm.  So "match a number" has grown from

	$MatchaFloat = qr'(?:\+|\-)?\d*\.?\d+';


	$MatchaScientific = qr'\d*\.?\d+(?i:e?\-?\d+)?';

To allow for sane drop-in overloading of these things,
the language, IMO, could break the operation of recognizing
numbers and massaging them into internal formats down into several
discrete and individually overloadable parts.  

	$MatchaComplex = qr'$(MatchaReal)(?:\+$(MatchaReal)i\b)';

Dependencies need to be explicit to avoid circularity, for instance
if my supercollider logs data in hexadecimal complex floating point
numbers I would want to redefine the $Internal::Numbers::MatchaReal
regex to include hex characters and to be case sensitive about the
E which is between D and F and the e which indicates point shift.

A Perl which is built on a modular "number" and starts
using pairs of long floats instead of single long floats as soon as
it sees a complex constant somewhere in the program -- sort of like
the whole prematch/postmatch situation -- might be neat; if its 
done right changing your internal real representation to bigrats or
full-text irrational descriptions in Klingon or whatever will transparently
allow complex numbers to use the same terms.

I don't know enough Klingon to write

	The fifth root of 7 plus imaginary pi raised to square root of 3

in it.  In fact I don't know any Klingon.

The above makes the unlikely presumption that one wouldn't just
preprocess highly weird formats into something easier to work with,
but there are situations where it makes sense to rewrite the 
IO/presentation parts of the numerics instead of requiring the machine
to do it twice: once between decimal and machine, and once between
whatever we really need, for instance base 60 numbers in cuneiform unicode.

We are planning on having an easy way to add printf conversions,
are we not?

                                           David Nicol 816.235.1187

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About