> On Fri, Sep 20, 2013 at 1:13 AM, Johannes Rudolph
> <
johannes...@googlemail.com> wrote:
>>
>> E.g. for a regexp interpolator that would add a strange special case.
>> Using a single escape character (i.e. for one parsing level) for all
>> purposes seems like the more natural solution, no?
>
>
> Well, sucks for the regex interpolator. "Natural" depends on what you're
> optimizing for. There may be an infinity of interpolators possible, but most
> people will only ever use one.
I see this as a consequence of making interpolators general without
allowing hooks into the parser. That said, I understand what you are
saying, there's a tradeoff between a cleaner design (just one
interpolation character) and easier migration (keep \"). Maybe there's
a third possibility: add '\"' as a special case and additionally add
'$"' for homogeneity and then also add '$\' for escaping the backslash
so that you are still able to encode the string backslash-doublequotes
without having to go into full quoted scala expression land.
> And interpolated strings are very often born
> out of uninterpolated ones, so a hundred times a day I am having to decide
> whether to go on another formatting adventure by making a string
> triple-quoted - oh it had embedded \ns, now I'm really screwed - or to
> commit some crime against aesthetics in the quest to avoid the need for a
> single quote. In the common activity of printing a List, I'd almost always
> rather see
>
> ${args mkString ", "}
>
> than
>
> $args
I don't see how this is related to the above but you are preaching to
the choir here. From 5 years ago:
/*
* ObjectFormatter.format("create table #name (#columns[#name #type
#specs(,)*\n](,)*)",t)
* is short for
* "create table" +
t.name + "(" +
* t.columns.map(c=>
c.name + " " + c.type + " " + c.specs.join(",")).join(",")
* + ")"
*/
https://github.com/jrudolph/bytecode/blob/174b430676c68755b2e37f364d63bdf04e7b6075/EnhancedString/src/net/virtualvoid/string/EnhancedStrings.scala#L14
(I've even got Scala code for this printed on dead trees in my bookshelf...)
Maybe it's time for a revival :)