Something like replacing the 1.1 with 1.1M or 11/10 before evaluating
the code?
I don't think so. The very first step of Clojure's expression
processing system, the reader, already interprets 1.1 as a floating-
point constant. You would need your own reader to give a different
meaning to the input string 1.1. However, the good news is that you
would only need a different reader, you could then plug its results
into the standard evaluation system.
Or, if you're taking a string from the user as your very first step,
you could (*choke*) apply regular expressions to append "M" to every
piece of floating-point syntax.
However, if those floating-point numbers come from some piece of
software other than a keyboard driver -- for example, they're read as
the value of a slider control -- then be careful of falsely assigning
decimal status to a string representation of a float...
Hacking Clojure's reader to replace the floating-point reader
shouldn't be too hard. Indeed, this might be something that can be
parameterized a la Common Lisp's radix/base settings.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en