On 2016-12-08 09:43, Joost Kremers wrote: >> (let ((password "letmein")) (fmt "The password is ${password}")) ⇒ >> "The password is letmein" > > Why the {}? Is there any context in which $ is ambiguous such > that ${} is needed to resolve it? Other than vectors, I mean Yes, unfortunately: you can include virtually anything in a Lisp variable name. (let* ((a 1) (b 2.0) (a/b (/ a b))) (fmt "$a/$b = ${a/b}")) > I honestly must say I find these last two very confusing. I would > simply write: > > (fmt "Today is $(format-time-string \"%Y-%m-%d\" current-time)).") > > The escaped double quotes are not perfect, but I find this much more > readable and more pleasant to look at. I really dislike the escaped quotes, but it might just be me :) This was inspired from Python's per-type format string, but I'm open to better syntax suggestions :) > Perhaps you should also look at abo-abo's hydra package, since he > does basically the same thing in his hydra doc strings. AFAICT, it > works this way: % starts a placeholder, ` marks the start of the > expression. If the expression is an s-expr, you can leave out the `. Thanks for the reference! Do you know how it knows where to stop after a backtick? > So, summarized: > > - % : format the value of where can be a symbol > or an s-expr, possibly also a vector or a string (somewhat > superfluously...) > > - %` : format according to . > > Of course, It might be easier to use a different symbol for %, I > don't know. I have nothing against using $. Thanks, that's a nice syntax too. I used $ based on a quick review of https://en.wikipedia.org/wiki/String_interpolation . I'm a bit worried about the lack of delimiter after `, though; maybe it would help to see what the example above (with $a/$b and $a/b) would look like in that syntax. >> fmt expands the strings at compile time (so they must be constant >> strings). > > I've occasionally appreciated the fact that I can pass a dynamically > created format string to `format'... ;-) Ok, I could always use > `format' in such cases. Yes; otherwise, fmt becomes a thinly veiled eval, and that isn't great. Cheers and thanks for the feedback! Clément.