The state of string interpolation...one year later

Jonathan Marler johnnymarler at gmail.com
Tue Mar 19 12:20:09 UTC 2019


On Tuesday, 19 March 2019 at 08:13:16 UTC, Kagamin wrote:
> On Monday, 18 March 2019 at 13:05:37 UTC, Steven Schveighoffer 
> wrote:
>> If you look at the PR that he created, it's super-simple. It 
>> uses the already existing parser/lexer in the front end.
>
> Hmm... the pr seemingly doesn't support full nested language: 
> the string is lexed as a normal double quoted string. This is 
> different from, say, javascript, where interpolated strings 
> support nesting without escapes and thus can't be lexed without 
> parsing all their content.
>
>> The point he's making is that we'd have to DUPLICATE that for 
>> a library solution.
>
> If they supported full nested language, but they don't. So I 
> see no reason to assume that they should be difficult to parse.

Your absolutely right here. Thanks for taking time to look at the 
code by the way. The current implementation isn't finished. I 
just wanted to start out with something easy to explore the 
feature. So today the language solution has the limitation that 
parens inside the code need to be balanced. But that limitation 
can be fixed with a bit more work. I just need to combine the 
current 2 pass interpolation logic into one-pass, but that would 
require some extra changes in the parse code and at this stage I 
wanted to minimize turmoil. So it's a temporary compromise. The 
final solution wouldn't have this limitation.



More information about the Digitalmars-d mailing list