login
 1 point by akkartik 3345 days ago | link | parent Yeah you're right that using period as both an infix op and inside floats is kinda messy. I use it a lot more than you, so I'm still going through the five stages of grief in giving it up. In the meantime I've hacked together support for floats. Basically, the reader tries to greedily scan in a float everytime it encounters a sym-op boundary. Some increasingly weird examples:`````` wart> e=5 wart> e-2.0 3 wart> e-3e-3 4.997 wart> 3e-3-e -4.997 `````` Perhaps this is reasonable. We have a rule that's simple to explain, whose implications can be subtle to work out, but which programmers are expected to exercise taste in using. That could describe all of lisp.

 2 points by rocketnia 3344 days ago | link "We have a rule that's simple to explain, whose implications can be subtle to work out, but which programmers are expected to exercise taste in using. That could describe all of lisp."I don't think the syntax for numbers is very easy to explain. That's the weak link, IMO.If it were me, I'd have no number literals, just a tool for translating number-like symbols into numbers. Of course, that approach would make arithmetic even less readable. :)I think the next simplest option is to treat digits as a separate partition of characters like the partitions for infix and non-infix. Digits are sufficient to represent unsigned bigints with a simple syntax. Then most of the additional features of C's float syntax could be addressed by other operators:`````` -20.002e23 ==> (neg (20.@1002 * 10^23)) `````` This hackish .@ operator, which simulates a decimal point, could be defined in Arc as follows:`````` (def dot-at (a b) (while (<= 2 b) (zap [/ _ 10] b)) (+ a (- b 1))) `````` You could avoid the need for this hack by treating . as a number character, but then you lose it as an operator.-----