Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upProposal: Adjacent string literal concatenation #55
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
getify
Jul 31, 2015
Contributor
We already have that:
gettext(`This is a string literal
written in multiple lines`);See: [https://github.com/lukehoban/es6features#template-strings](Template Strings)
|
We already have that: gettext(`This is a string literal
written in multiple lines`);See: [https://github.com/lukehoban/es6features#template-strings](Template Strings) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shovon
commented
Jul 31, 2015
|
@getify also relevant: http://programmers.stackexchange.com/a/255021/17183 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kentor
Aug 1, 2015
@getify @michaelficarra Right, if I were to indent the block containing the template string, I would add spaces in between literal and written. Also the \n character may not be desired.
I'm running my javascript through django's makemessages for translations, and it looks for strings in between gettext (static analysis I think). If the spaces are introduced it will think the source string has changed. I'm concatenating using + for now to avoid the problem, but it would just be a nice feature not to have to do that.
Also this could perhaps be a performance boost depending on the environment/VM. I definitely see it being transpiled to a single string without using +.
kentor
commented
Aug 1, 2015
|
@getify @michaelficarra Right, if I were to indent the block containing the template string, I would add spaces in between I'm running my javascript through django's Also this could perhaps be a performance boost depending on the environment/VM. I definitely see it being transpiled to a single string without using |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shovon
Aug 1, 2015
Also this could perhaps be a performance boost depending on the environment/VM. I definitely see it being transpiled to a single string without using
+.
Yeah, that's definitely a big win.
shovon
commented
Aug 1, 2015
Yeah, that's definitely a big win. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pluma
Aug 3, 2015
Here's the relevant part of the official Python reference: https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals
Ditto for Ruby: http://ruby-doc.org/core-2.2.0/doc/syntax/literals_rdoc.html#label-Strings
pluma
commented
Aug 3, 2015
|
Here's the relevant part of the official Python reference: https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals Ditto for Ruby: http://ruby-doc.org/core-2.2.0/doc/syntax/literals_rdoc.html#label-Strings |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Sep 22, 2015
Member
Closing this now. Proposals should have an identified champion and repository set up where work happens. This is not the place to brainstorm about proposals.
|
Closing this now. Proposals should have an identified champion and repository set up where work happens. This is not the place to brainstorm about proposals. |
kentor commentedJul 31, 2015
This would be great when breaking up strings into multiple lines in the source code. It would save us from writing a
+for every line break. This is a feature present in C, Python, and Ruby. It's most useful when your style guide enforces max characters per line and you want to keep a level of indentation.Example:
should be transpiled to a single string.
Other thoughts: