-
Notifications
You must be signed in to change notification settings - Fork 198
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
Raw strings #6306
Comments
I like this solution, Chris. I found it quite interesting that by changing the quantity of # at the beginning and end of the string, it allows the use of this character within the string. |
@Chriscbr I think this is implemented right? |
@eladb Right now we have "non-interpolated strings" which allow you to create strings like "foo{bar}" without interpolating variables for you. But characters like backslashes and quotes are still require escaping if you want to use them. |
I see. Any reason not to merge these use cases and make non-interpolated strings into raw strings? Is it really valuable to 3 types of string literals in the language? |
Yup, exactly - I think they can combined 👍 |
Hi, This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Use Case
As a user, I would like a way to create strings that allow me to type special characters like backslashes without having them treated as escape sequences. Likewise, I would like to be able to type quotes without having to escape them every time.
Here are some examples where I need to modify my string in order to use it in my Wing source code:
Proposed Solution
Perhaps we can reuse the non-interpolated string syntax from #6290, and change it so that it requires a trailing
#
, so we would end up with:This is more or less similar to the design of Swift's raw strings (examples, RFC).
In cases where you want use the closing delimiter
"#
in your string, then the user can add more #'s:Implementation Notes
JavaScript has a way to obtain raw strings that could be useful: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw. Or maybe it would be easier to do the escaping within Wing's parser - not sure.
Component
Language Design
Community Notes
The text was updated successfully, but these errors were encountered: