Skip to content

Splitting string literals into multiple literals? #256

@osa1

Description

@osa1

We currently have no way of splitting a long string into smaller strings, without having to do runtime concatenation and hope that it'll optimize.

This was mostly fine until #255, but with #255 we now format interpolated expressions, and that means if I have a long string with interpolations, it gets broken into multiple lines in weird ways.

If we allow splitting a literal into multiple literals in a way that is guaranteed to generate a single string (no runtime concatenation), users can split long strings with interpolations into shorter ones manually to have nicely formatted strings.

My current thinking is that we can allow juxtaposition of string literals. (1) it requires no new syntax (2) it's a well known syntax, supported by many languages (3) it's easy to parse.

The footgun of ["a" "b", "c"] (note the missing comma) may be avoided if we format merge short strings and format this example as ["ab", "c"]. (this assumes that all Fir code will be formatted always)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions