[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Engineering numbers again ...

Thanks for the feedback ! .. I have FTPMAIL'ed for the infix reader and
I have reached down CLtL2 one more time. I guess I am missing something
- I see how the set-macro-character stuff works and I know about bashing
the readtable and set-syntax-from-character and stuff - but I still don't
see how to make it read my engineering things as numbers.

This I understand: (+ 3.14 #E3.4k) - the #E says escape and read the
next thing with some special code.

This I understand: {3.4k + 9.1k} - the { introduces some funky
environment where I can take control of the reader.

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:

T == 1e12
G == 1e9
ME == 1e6
K == 1e3
m == 1e-3
u == 1e-6
n == 1e-9
p == 1e-12
f == 1e-15
a == 1e-18

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.

If I (read-from-string "3.4k") a symbol is consed up, if I
(read-from-string "3.4e0") a number is consed up: where is the hook for
me to tell the reader about the "k" being something special that, like
the "e", is just part of the printed representation of a number? - in
this case a factor to be applied to the number...

I'll look at the "infix.lisp" example when I receive it - perhaps I am
making a more of this than necessary due to my misunderstanding.

Martin Mallinson                                martin@cmt.dialnet.symbolics.com

Crimble Micro Test Inc.                              
5 Tomahawk Drive                                Phone: 508 667 9405
Billerica MA 01821                              Fax:   508 667 0192