[ 
https://issues.apache.org/jira/browse/GROOVY-9442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King updated GROOVY-9442:
------------------------------
    Description: 
The goal is to add {{\s}} as an additional escape sequence for single and 
double quoted strings.

{code}
assert 'ab\scd\s'.bytes == [97, 98, 32, 99, 100, 32]
{code}

Relevant section from the Java issue tracker ([JEP 368: Text Blocks (Second 
Preview)|https://bugs.openjdk.java.net/browse/JDK-8231623]):
{quote}
 !screenshot-1.png! 
{quote}

This isn't a breaking change since:
 * illegal escape sequences are currently an error for single and triple 
(multi-line) single/double quoted strings
 * slashy and dollar slashy strings ignore backslash escape sequences (apart 
from special cases)

The use case cited in Java is to allow explicit indication of spaces at the end 
of a line in a multi-line string. This is then explicit for human readers or 
editors that might auto-remove trailing spaces. It becomes more important in 
recent versions of Java with auto-removal of incidental whitespace in 
multi-line strings.

The only -ve I can see is regex users who might get regex \s mixed up with this 
new escape. But we already have that issue for \b (backspace in normal string 
vs word boundary in regex).

  was:
The goal is to add {{\s}} as an additional escape sequence for single and 
double quoted strings.

{code}
assert 'ab\scd\s'.bytes == [97, 98, 32, 99, 100, 32]
{code}

Relevant section from the Java issue tracker ([JEP 368: Text Blocks (Second 
Preview)|https://bugs.openjdk.java.net/browse/JDK-8231623]):
{quote}

{quote}

This isn't a breaking change since:
 * illegal escape sequences are currently an error for single and triple 
(multi-line) single/double quoted strings
 * slashy and dollar slashy strings ignore backslash escape sequences (apart 
from special cases)

The use case cited in Java is to allow explicit indication of spaces at the end 
of a line in a multi-line string. This is then explicit for human readers or 
editors that might auto-remove trailing spaces. It becomes more important in 
recent versions of Java with auto-removal of incidental whitespace in 
multi-line strings.

The only -ve I can see is regex users who might get regex \s mixed up with this 
new escape. But we already have that issue for \b (backspace in normal string 
vs word boundary in regex).


> Support for the new JDK14 string escape sequence (\s for single space)
> ----------------------------------------------------------------------
>
>                 Key: GROOVY-9442
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9442
>             Project: Groovy
>          Issue Type: New Feature
>          Components: GEP
>            Reporter: Paul King
>            Priority: Major
>         Attachments: screenshot-1.png
>
>
> The goal is to add {{\s}} as an additional escape sequence for single and 
> double quoted strings.
> {code}
> assert 'ab\scd\s'.bytes == [97, 98, 32, 99, 100, 32]
> {code}
> Relevant section from the Java issue tracker ([JEP 368: Text Blocks (Second 
> Preview)|https://bugs.openjdk.java.net/browse/JDK-8231623]):
> {quote}
>  !screenshot-1.png! 
> {quote}
> This isn't a breaking change since:
>  * illegal escape sequences are currently an error for single and triple 
> (multi-line) single/double quoted strings
>  * slashy and dollar slashy strings ignore backslash escape sequences (apart 
> from special cases)
> The use case cited in Java is to allow explicit indication of spaces at the 
> end of a line in a multi-line string. This is then explicit for human readers 
> or editors that might auto-remove trailing spaces. It becomes more important 
> in recent versions of Java with auto-removal of incidental whitespace in 
> multi-line strings.
> The only -ve I can see is regex users who might get regex \s mixed up with 
> this new escape. But we already have that issue for \b (backspace in normal 
> string vs word boundary in regex).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to