The state of string interpolation

Sjoerd Nijboer dlang at sjoerdnijboer.com
Tue Dec 11 17:12:46 UTC 2018


On Tuesday, 11 December 2018 at 16:48:56 UTC, Paul Backus wrote:
> It sounds like what you're asking for is a way to define rules 
> for "lowering" one kind of syntax (e.g., string literals) into 
> another (e.g., calls to library functions or templates).

Maybe I explained it a littl weird, but I would really like D to 
not have AST macros that are accessible for the programmer. Like 
you explained, it makes the language into whatever the one who 
created the library wanted to be. Which probably isn't a good 
thing for a language like D.

I think that there might be realistically 5 or 8 or so syntactic 
sugar features people generally want in this language, and I 
think the compiler could provide that. This could be done using 
AST's, but should not be accessible to the programmer.
At most, I think this would add some compiler swithces like `dmd 
--syntaxextention=interpolation,null-conditional,etc...`
That way they would be defined by the D community, W&A wouldn't 
have to "deal" with it, the people who want their sugar have it, 
and the people who never ever want to touch it don't have to.

The biggest benefit I think of doing it this way is 
standardisation. Because if it were to be done with a library 
implementation, there will probably be a few libraries which will 
implement it with various syntax and in various stages of 
working. Furtheron, people would have to learn a library instead 
of a language feature, which on itsself isn't such big of a deal 
except that there are probably multiple libraries doing thesame 
thing, and libraries are harder to find documentation for. Its 
always annoying in a professional project to have to add external 
dependencies for small features. It becomes a liability and makes 
D less attractive.



More information about the Digitalmars-d mailing list