Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
String Interpolation in Clojure (muckandbrass.com)
40 points by fogus on Dec 4, 2009 | hide | past | favorite | 5 comments


Strings cannot be used within interpolated expressions; e.g. this will cause a straightforward parse exception

This ought to be pretty straightforward to fix by escaping the quotes via \"


Sure, but that's not what you'd like to have happen in the end (though it works in a pinch). I mentioned it because it was one of the issues that is insurmountable from userland right now.


cemerick, I've hacked both Ruby & Clojure, so I can comment on the way Ruby handles stings.

Ruby has a concept of a 'string', as opposed to a "string". 'This is strict input, no escapes' "This is input with escapes"

I think that the suggested \" method is the best solution in Clojure.


You could just pick a different delimiter for strings within the interpolated string, and do a string-replace-all with \" before parsing. (although then you have to find delimiters that aren't used in the language normally, possibly the | or something).


Super cool.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: