Invisible link to canonical for Microformats

ADR-014 Raw Strings using Single Quotes


Status

Accepted

Context

The language currently supports interpreted strings using double quotes ("..." and """..."""), which process escape sequences (like \n) and string interpolation (via ``).

There is a need for “raw” strings where backslashes and other characters are treated literally. This is particularly useful for:

  1. Regular Expressions and Paths: Avoiding “backslash-itis”.
  2. Template Definitions: The language intends to support Mustache as a template library. Since Mustache uses `` as its own delimiters, defining a Mustache template within an interpreted string would require excessive escaping of the host language’s interpolation markers.

Decision

We will implement raw strings using single quotes (') to provide a clear distinction from interpreted double-quote strings.

Strictly Literal (WYSIWYG)

Raw strings will follow a strictly literal model. No characters are processed as escape sequences or interpolation markers.

  • 'C:\Users\Name' results in the literal backslashes being preserved.
  • '' results in a literal string, allowing Mustache templates to be defined without escaping.

Single and Multi-line Support

  • Single-line raw strings: Delimited by '... '.
  • Multi-line raw strings: Delimited by '''...'''.

Delimiter Collision Handling

To include a single quote within a raw string, the user must use the multi-line variant (triple single quotes). There is no escape character (like \') within raw strings.

Consequences

Positive

  • Simplicity: Users have a simple mental model: Single quotes are literal, double quotes are interpreted.
  • Template Friendly: Defining Mustache or other `` based templates is trivial.
  • Solves Nested Quote Issues: Users can now use interpreted strings inside interpolation blocks without collision by using single quotes for internal keys, e.g., "".

Negative

  • No Escaping: If a string contains both ' and ''', it cannot be represented in a raw string without modification.

Neutral

  • Consistent Delimiters: Follows the pattern of languages like Python or Ruby where quote type signifies behavior, but adopts stricter raw content rules.