A Common Lisp format function for Clojure now up

5 views
Skip to first unread message

Tom Faulhaber

unread,
Dec 22, 2008, 2:30:47 AM12/22/08
to Clojure
Good Evening Clojurians,

I have been working on a Clojure implementation of the format function
from Common Lisp and it's coming along well enough that I thought I'd
share.

You can see/download the current state of it in its github project:
http://github.com/tomfaulhaber/cl-format/

It's currently about 2/3 complete including iteration, conditionals,
and floating point in all their various flavors. I'm finding that it's
already a lot more useful than the Java format, but that might just be
my bias :-). The README on github has a detailed implementation status
that I keep up-to-date.

If you don't know about Common Lisp's super-powerful format function,
you can check it out here, in "Practical Common Lisp,"
http://www.gigamonkeys.com/book/a-few-format-recipes.html or here, in
"Common Lisp the Language,"
http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html.

I'm definitely interested in feedback on it in terms of style, on what
you're using it for, and on what features you'd like to see next. I
also want to hear about bugs. I'm sure there are plenty!

You can add feedback here, via github or find me as "replaca" on
#clojure.

Enjoy!

Tom

Remco van 't Veer

unread,
Dec 22, 2008, 3:55:32 AM12/22/08
to clo...@googlegroups.com
Good morning Tom,

Skimming through the code I found:

(defmacro aif
[test then-form else-form]
`(let [~'it ~test]
(if ~test
~then-form
~else-form)))

The test form is evaluated twice, probably not what you want. You
could replace this macro with an (or ..) form. The only place this
macro is used (format.clj line 385):

expchar (aif (:exponentchar params) it \E)

would become:

expchar (or (:exponentchar params) \E)

Regards,
Remco

Tom Faulhaber

unread,
Dec 22, 2008, 11:45:03 AM12/22/08
to Clojure
Remco,

Right on both counts. I have modified it to use the (or ...) form as
you suggest.

Thanks,

Tom

Josip Gracin

unread,
Dec 22, 2008, 3:36:44 PM12/22/08
to clo...@googlegroups.com
On Mon, Dec 22, 2008 at 8:30 AM, Tom Faulhaber <tomfau...@gmail.com> wrote:
> You can see/download the current state of it in its github project:
> http://github.com/tomfaulhaber/cl-format/

Great job! CL format is a great tool.

Reply all
Reply to author
Forward
0 new messages