funcool / cuerdas

String manipulation library for Clojure(Script)
https://cljdoc.org/d/funcool/cuerdas/2020.03.26-3/
BSD 2-Clause "Simplified" License
304 stars 30 forks source link

Naming of string interpolation #43

Closed emlyn closed 8 years ago

emlyn commented 8 years ago

I'm really liking the new string interpolation macro. However, while I understand the name (<<) is meant to be inspired by bash's heredoc syntax, I find it a bit unintuitive (making me think instead of C++ streaming / bit shifting operators, or some variation of Clojure's threading macros).

I thought that maybe ~ would be a better name, given that it is also the character used to start an interpolation inside the string. Also, it is not really used much as an operator in other languages, so might be less confusing.

Or maybe a completely different character could be used as both the name and the escape character to start interpolation (e.g. $?).

What do you think?

niwinz commented 8 years ago

I agree with you, I'm also not very happy with the current naming, but I don't know a better one. The ~ seems a good candidate to be an alias. Any other ideas?

emlyn commented 8 years ago

I also quite like $, if the escape character is also changed to match, like: ($ "Value = ${value}"). In fact, I think it's much more intuitive than ~ inside the string.

niwinz commented 8 years ago

~ is a character used in clojure as syntax-unquote reader macro, and is very familiar, this is because is used and I like the current approach. In other hand use ~ as function/macro name is not convincing me... I don't know a better alternative right now...

emlyn commented 8 years ago

Ah that makes sense, I should have noticed :-) Here are a few ideas for the macro name, I'm not completely convinced by any of them, but might be a starting point for discussion:

niwinz commented 8 years ago

I have choiced istr ;) thanks