FFFF Let keywords name methods, follow '.', and label parameters (record, after, public, private, …) · Issue #508 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Let keywords name methods, follow '.', and label parameters (record, after, public, private, …) #508

Closed

Description

@akoskovacs

A keyword can't name a method, can't follow ., and can't be a parameter name, even where nothing else could be meant:

record Insert do
  row : {String: Any} = {}
end

make Insert do
  let record(value: Any) -> Insert = this
end

main do
  Insert {}.record(1)
end
error: `record` is a reserved keyword in Kex, so it cannot name a function — rename it
error: Expected method or module name after '.'
error: Expected record name, got (

The same thing happens with after as a parameter name (foul rebuilding(before: Column, after: Column) fails with "Expected parameter"), and with public, private, next and type wherever a word reads best.

Proposal: read a keyword as a plain name where it names a make-block method, follows ., or labels a parameter or named argument. In those places it can't start the construct the keyword stands for. Kotlin's soft keywords and Swift's backticked identifiers are two ways other languages do this.

Where it bit

Each of these was renamed to a weaker word (Slick's docs/kex-findings.md, "Names to change back"):

  • Harmat's Insert.record(…) is valuesOf(…).
  • A migration's before/after columns are prior/changed.
  • Slick's Conversation.public? is open?.
  • Messages.newer(…, since:) stands in for after:.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0