Skip to content

Prefixed string/char literals #1734

@lbajolet

Description

@lbajolet

Unicode is good, unicode is great, but it has a few undesirable pitfalls sometimes:

For these uses, no real easy solution exists now in Nit.
As such, this issue proposes the introduction of prefixed strings and chars.
It will first be recognized grammatically, and some prefixes will be implemented in the compiler later.

Some candidate prefixes on strings are:

  • b"Byte\xfe" => for a byte string with potentially invalid unicode chars in it.
  • re"\w*?+" => for Regular Expressions
  • raw"\n\rEscaped" => For raw strings, where escape sequences are treated as normal characters

Some candidate prefixes on chars are:

  • a'\n' => ASCII value of char '\n' as a Byte
  • u'𐏓' => Unicode code-point of char '𐏓' as an Int

This issue is also a feature request for people wishing for more specific or exotic prefixes, this is the place and the moment to express your needs :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions