[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Engineering numbers again ...
>> I don't want either of these, I just want 3,4k to be read as 34.0e3, 5.6u
>> to be read as 5.6e-6, 4p to be read as 4e-12 etc. The complete set is:
>> I can't see the hook into the reader code that allows it to be halfway
>> down the string "123.45e6" nicely reading the "123.45", hits the "e" and
>> figures "whoops this must be a floating point number, exponent coming up
>> next". Notice it doesn't know its an exponential format number 'till it
>> hits the "e". CLtL2 seems to gives me the ability to say #E3.4k
>> analogous to #C(1 2). But these are prefixes.
Prefixes is all Common Lisp gives you. A general mechanism for
fiddling with the reader would be overkill.
You can still do what you want, perhaps a bit laboriously, by defining
your own reader functions for all tokens starting with a digit or -
(see SET-MACRO-CHARACTER). You'll have to do some parsing yourself,
but you can get help from the standard reader using READ-FROM-STRING
with the standard readtable on selected parts of your token.