Pure Bikeshedding: Raw Strings (why yes, again!)

Well, we really want two different things: an alternate delimiter and a raw literal. '' can sometimes act as an alternate delimiter when a string contains " but not ' and it doesn't matter whether the contents are raw or "cooked", but it's not primarily an alternate delimiter feature, any more than multiline string literals are.

My current thought on alternate delimiters is that we should put ` before the opening quote and after the closing one:

print(`""No Raw Loops" --Dave Abrahams's coworker"`)

If you have a backtick in your string, you can use two backticks on each end, etc. You can also use `'...'` for a raw string with alternate delimiters, `"""..."""` for a multiline string, `'''...'''` for a raw multiline string, etc.

This would not conflict with any currently valid syntax—neither ", ', nor ` is valid immediately following a backtick, and there isn't even much weird "let's diagnose some common invalid code" logic in the backtick handling, so it's a truly unused corner of the language. I don't think there's any direct precedent for this syntax in other languages, but it's somewhat similar to our use of backticks to escape identifiers which match keywords.

Edit to show all permutations of these features (well, I can't show every alternate delimiter, they're infinite):

// "Cooked" literal
print("C:\\AUTOEXEC.BAT")
// Raw literal
print('C:\AUTOEXEC.BAT')

// Alternate "cooked" literal
print(`"print("C:\\\\AUTOEXEC.BAT")"`)
// Alternate raw literal
print(`'print('C:\AUTOEXEC.BAT')'`)

// Alternate (2) "cooked" literal
print(``"print(`"print("C:\\\\\\\\AUTOEXEC.BAT")"`)"``)
// Alternate (2) raw literal
print(``'print(`'print('C:\AUTOEXEC.BAT')'`)'``)

// Alternate 3+ omitted to prevent running out of memory and/or author lifespan

// "Cooked" multiline literal
print("""
        print("C:\\\\AUTOEXEC.BAT")
        print('C:\\AUTOEXEC.BAT')
        print(`"print("C:\\\\\\\\AUTOEXEC.BAT")"`)
        print(`'print('C:\\AUTOEXEC.BAT')'`)
        """)
// Raw multiline literal:
print('''
        print("C:\\AUTOEXEC.BAT")
        print('C:\AUTOEXEC.BAT')
        print(`"print("C:\\\\AUTOEXEC.BAT")"`)
        print(`'print('C:\AUTOEXEC.BAT')'`)
        ''')

// Alternate "cooked" multiline literal
print(`"""
         print("""
                print("C:\\\\\\\\AUTOEXEC.BAT")
                print('C:\\\\AUTOEXEC.BAT')
                print(`"print("C:\\\\\\\\\\\\\\\\AUTOEXEC.BAT")"`)
                print(`'print('C:\\\\AUTOEXEC.BAT')'`)
                """)
        """`)
// Alternate raw multiline string literal:
print(`'''
         print('''
                print("C:\\AUTOEXEC.BAT")
                print('C:\AUTOEXEC.BAT')
                print(`"print("C:\\\\AUTOEXEC.BAT")"`)
                print(`'print('C:\AUTOEXEC.BAT')'`)
                ''')
        '''`)

// Alternate (2) "cooked" multiline literal
print(``"""
          print(`"""
                  print("""
                         print("C:\\\\\\\\\\\\\\\\AUTOEXEC.BAT")
                         print('C:\\\\\\\\AUTOEXEC.BAT')
                         print(`"print("C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\AUTOEXEC.BAT")"`)
                         print(`'print('C:\\\\\\\\AUTOEXEC.BAT')'`)
                         """)
                 """`)
         """``)
// Alternate (2) raw multiline string literal:
print(``'''
          print(`'''
                  print('''
                         print("C:\\AUTOEXEC.BAT")
                         print('C:\AUTOEXEC.BAT')
                         print(`"print("C:\\\\AUTOEXEC.BAT")"`)
                         print(`'print('C:\AUTOEXEC.BAT')'`)
                         ''')
                 '''`)
         '''``)

// Alternate 3+ omitted to prevent running out of memory and/or author lifespan, again
1 Like