Reconsidering the syntax of $R"(text)"
#733
Replies: 2 comments 3 replies
-
I see no captures outside strings here. |
Beta Was this translation helpful? Give feedback.
-
Thanks @JohelEGP, so the implementation and code generation would be something similar to this: func_signature: = "(x: i32)";
// Which one does it mean?
x.add_member($R"x( func: (func_signature)$R"(text)" )x");
// Case 1 -------> `func: (x: i32) R"(text)"`
x.add_member($R"x( func: (func_signature)$ R"(text)" )x");
// Case 2 -------> `func: (func_signature) $R"(text)"`
x.add_member($R"x( func: (func_signature) $R"(text)" )x"); According to the question, Case 1 is the answer. It would be possible to require programmers to add extra white-space if they want Case 2. But requiring white-space can be relaxed if we had another syntax for raw interpolated string literals. Requiring white-space in Cpp2 syntax, would make it hard to arbitrary format the code. In other words, less white-space requirements brings better code format options. I (as a novice programmer) learned to think about
That's not a problem, a symbol can have as many meanings as it doesn't conflict with each other, but while generating code inside a meta function, it would be desirable that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
IMO
$R"(text)"
is an example of too smart syntax for raw interpolated string literals. It's visually misleading especially with captures. This is an example for code generation:The example doesn't work today and I don't know if we can use captures to specify a function signature in code generation, or if we can capture from raw interpolated string literals. Also the white-space can be used to resolve the ambiguity, but
$
itself is visually misleading to form a string literal if we consider readability. Also it requires more characters to type. Would it be possible to reconsider changing the$R
in syntax$R"(text)"
to a single letter?r"(text)"
, becauser
isn't as strong asR
.I"(text)"
, becauseI
is the first letter of Interpolated.S"(text)"
, becauseS
visually looks like$
.Thanks.
Beta Was this translation helpful? Give feedback.
All reactions