-
Notifications
You must be signed in to change notification settings - Fork 16
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
Reconsider syntax proposal #76
Comments
I don't think the question of how to handle caching is significant enough to warrant revisiting syntax. It's really only relevant in an edge case which most people will never encounter. |
With MySQL, the following situations are common. const query = `
select *
from \`users\`
where \`name\` = ?
` If implemented via In the "In other languages" section of the README, the grammar(heredoc) is implemented separately from the default string( |
If we are to introduce new syntax, we should make it worthwhile by including more features and solving as many problems as possible, otherwise the features proposed too late will become breaking changes in the future. Here is my proposal of adding raw string literal to ECMAScript/JavaScript to solve multiple problems together:
(Mentioned in #40 as well) |
Does this feature compose with other tagged template literals? e.g.:
If not please reconsider a syntax-based solution that will work with existing tagged-template literals. |
Yes: const mySql = String.dedent(sql)`
SELECT *
FROM myTable...
`; |
@sken130 I really like your proposal, but you need a champion (TC39 delegate) to bring it to the committee. 😉 |
@bakkot What if we want compose more? For example, also compose |
@hax You already can't compose |
Hi everyone, I plan to write a raw string syntax proposal (maybe based on @sken130 work) and present to the committee for stage 1, if I can catch the deadline of next meeting. Besides the use cases this issue or @sken130 's discourse post already mentioned, the main reason I decide to champion it myself is because I feel really pain when writing LLM code in JS --- if you want to write prompt in markdown or contains JS code directly in the prompts. I will update this issue when the proposal repo ready. |
Please check the repo: https://github.com/hax/proposal-raw-string-literals @sken130 Feel free to add your real name to authors if you wish. |
I suggest we reconsider syntax option because with syntax, we just solve #75.
There are also other reasons, copy from original issue:
One problem of current template literal is, you can't have unescaped
`
in the literal (it always end the literal). This is very inconvenient for text contains backticks, eg. markdown.This issue is not directly relate to dedent, but consider the main use cases of dedent is long text, I really hope we can revisit the syntax options which could allow unescaped backticks.
Syntax also make
String.dedent(tag)
unnecessary. I feelString.dedent(tag)
is a little bit hard to understand for average programmers, andString.dedent(obj.foo)
may not work. (needString.dedent(obj.foo.bind(obj))
.)Originally posted by @hax in #40 (comment)
The text was updated successfully, but these errors were encountered: