Skip to content

Syntax for raw identifiers #2534

Description

@L0r3m1p5um

There's a problem that sometimes comes up with recursive references to record fields, which is that a field name can be defined to a value that is not a valid identifier in other contexts. That can make it impossible to reference some record fields recursively. For example, a record field with the same name as a keyword can't be referenced:

nickel> { priority = "high", x = priority }
error: unexpected token
  ┌─ <repl-input-3>:1:26
  │
1 │ { priority = "high", x = priority }
  │                          ^^^^^^^^

Another example is field names with a period:

nickel> { "some.property" = 1, x = some.property }
error: unbound identifier `some`
  ┌─ <repl-input-4>:1:28
  │
1 │ { "some.property" = 1, x = some.property }
  │                            ^^^^ this identifier is unbound

One solution that I think was discussed in the discord a while back is to have a way to create raw identifiers, like id%"some.property"%.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions