You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since a primary use of interpolation strings is mixins, requiring escapes in interpolation strings becomes very cumbersome. For example, to include a \n in the mixin, you need to escape the backslash. Ditto with double quotes.
It also isn't clear whether escapes are needed. The grammar does not support it. All the grammar has is the same for double quoted strings, and then (I'm assuming) once parsed, you have to parse any interpolation sequences according to the secondary grammar. What if there are characters that need escapes inside the interpolation? e.g. are these backslashes needed?
If not needed, the grammar doesn't reflect this. If needed, this is going to be a lot less attractive for mixins.
For reference, DIP1036 encodes the grammar of the expressions directly in the string type. It's not much more grammar, although it is repetitive. But the benefit is that it's clear that escapes are not needed for the interpolation sequences.
And finally, it seems odd that all other escapes in double quoted strings use backslashes, yet interpolation tokens use double $. Would it make sense to simply add \$ to the list (this is what I did in DIP1036)?
The text was updated successfully, but these errors were encountered:
Forgot to bring up, one of the reasons I'm making this point is that we already have string types that support WYSIWYG strings which are great for mixins. Why not add those to the mix as well (with an i prefix)?
Since a primary use of interpolation strings is mixins, requiring escapes in interpolation strings becomes very cumbersome. For example, to include a
\n
in the mixin, you need to escape the backslash. Ditto with double quotes.It also isn't clear whether escapes are needed. The grammar does not support it. All the grammar has is the same for double quoted strings, and then (I'm assuming) once parsed, you have to parse any interpolation sequences according to the secondary grammar. What if there are characters that need escapes inside the interpolation? e.g. are these backslashes needed?
i"Hello $(capitalize(lastname ~ \", \" ~ firstname))"
If not needed, the grammar doesn't reflect this. If needed, this is going to be a lot less attractive for mixins.
For reference, DIP1036 encodes the grammar of the expressions directly in the string type. It's not much more grammar, although it is repetitive. But the benefit is that it's clear that escapes are not needed for the interpolation sequences.
And finally, it seems odd that all other escapes in double quoted strings use backslashes, yet interpolation tokens use double $. Would it make sense to simply add
\$
to the list (this is what I did in DIP1036)?The text was updated successfully, but these errors were encountered: