Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double quoted strings and escapes #9

Open
schveiguy opened this issue May 20, 2021 · 1 comment
Open

Double quoted strings and escapes #9

schveiguy opened this issue May 20, 2021 · 1 comment

Comments

@schveiguy
Copy link
Collaborator

schveiguy commented May 20, 2021

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)?

@schveiguy
Copy link
Collaborator Author

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant