Is it possible to use lisp's macro to do string interpolation?
For instance, can I make a macro like this:
(defmacro test (a) `",a")
So that (test abc) returns "abc" as a string? I could probably cheat by quoting it and turning that quote into a string, but that doesn't work for arguments like "9:00" (without double quotes).
Lisp macros operate on arguments that have already been read by lisp's reader. Because of that a macro can't change how it's arguments are read, and if you pass an argument that will signal an error when you try to read it, e.g.
9:00
in(test 9:00)
, the reader signals the error before the macro even starts to run.The reader is also customizable. Not in a way that would let you read
9:00
as"9:00"
in a straightforward manner, but for example you could write a short reader macro that read@9:00
as either"9:00"
or as a date object.Edit: Something like this: