Feedback Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Kagamin
spam at here.lot
Sat Jan 30 07:27:04 UTC 2021
On Friday, 29 January 2021 at 13:57:49 UTC, Steven Schveighoffer
wrote:
> DoubleQuotedString is the only string with EscapeSequence
> processing. Therefore we continued that same expectation. The
> Wysiwyg string types specifically allow single backslash to
> represent a backslash, and we did not want to change that
> behavior.
It's the same as using wysiwyg string to write regex with escape
sequence: `\.+`, already existing practice for the principle of
least surprise.
> In TokenString, the sequence ${ tokens } are not valid D
> tokens, so escaping the sequence isn't fruitful. It may be
> something that is reasonable inside a string literal inside the
> token string, but I don't think that's worth the complexity. If
> you want escapes, use the double quoted form.
The reason is to reduce complexity by reusing existing string
syntax. You currently propose a whole new group of string
syntaxes, which increases complexity, they are so new they can't
even be easily understood by looking at them. By the way, dollar
and curly braces are valid tokens of course.
> Note also, to wait until the entire string is lexed to process
> the interpolation sequences means the sequences would have to
> obey the rules of the string. This means something like:
>
> i"hello ${firstname ~ " " ~ lastname}"
Yes, I see that as two juxtaposed strings. Again, it's nothing
new, double quoted strings have this problem, and D provides
plenty of string syntaxes to solve it, like backtick string.
> The lexer already has the capability of processing token
> strings, which is essentially what this is. It's just in the
> middle of another string sequence.
The reason token string uses curly braces instead of quotes is
that in simple case you don't even need to be aware of token
strings, they will just lex as tokens. dmd is not the only tool
that works with D code.
More information about the Digitalmars-d
mailing list