savi icon indicating copy to clipboard operation
savi copied to clipboard

Extension points for string literals

Open jemc opened this issue 3 years ago • 2 comments

We currently have "normal" string literals (no prefix) and "byte string" literals (b prefix), but we have no extension points for allowing users to add their own prefixes, as Elixir does.

We likely want to add this at some point, but at this time I don't consider it essential for Savi v1.0.0.

jemc avatar Mar 06 '22 17:03 jemc

also see C++ 11's user-defined literals: https://en.cppreference.com/w/cpp/language/user_literal which not only applies to strings, but also numerical literals. I have no clear opinion whether it's worth having such support... though 12_km reads better than Km(12)...

mneumann avatar Mar 07 '22 06:03 mneumann

String literals of other types should support having different escape sequences.

For example, a Regex literal (defined by the Regex package, outside the core language) should be able to have escape sequences like \d or \w in it. Currently, we need to type these as \\d or \\w because the Savi compiler now disallows unknown escape sequences (as of #353).

jemc avatar Sep 11 '22 14:09 jemc