Language Design: Naming Conventions

Part 1: Creation

Published on 2018-06-19. Last updated on 2022-06-24
Name Example Explanation
List(1, 2, 3) Array(12.3, 45.6) Set("a", "b", "c")
  • primary way of construction
  • resulting instance contains provided arguments verbatim
of(val1, ...) Person.of(name, age)
  • secondary way of construction
  • resulting instance contains provided arguments verbatim
  • result type might use Option or Result types to encode failures
from(val) Person.from(personEntity) Person.from(family)
  • tertiary way of construction
  • arguments are extracted, adapted, and/or converted
  • the value of the instance is derived from the provided arguments
  • result type is likely to use Option or Result types to encode failures
parse(string) Person.parse(string) Int64.parse(string)
  • quaternary way of construction
  • argument is parsed from a less structured representation, such as strings
  • result type is highly likely to use Option or Result types to encode failures
with(val) person.withAge(23) person.with(age = 23)
  • returns a copy of a value with parts replaced by the provided argument