Language Design: Naming

Published on 2018-06-19.
Name Example Explanation
List(1, 2, 3),
Array(12.3, 45.6),
Set("a", "b", "c")
primary way of construction, wrapping;
resulting instance contains passed arguments verbatim
of Person.of(name, age) secondary way of construction, wrapping;
resulting instance contains passed arguments verbatim
from Person.from(string),
Person.fromString(string),
Person.from[String](string)
arguments are adapted, converted or parsed;
the value of the instance is derived and does not contain the passed arguments verbatim;
result type is likely to use Option or Result types to signal construction failures
to array.toList,
int.toDouble,
array.to(List),
int.to(Double)
implies a conversion of some sort
as int.asDouble,
int.as(Double),
longBuffer.asByteBuffer,
map.asSetOfEntries,
setOfEntries.asMap
implies a reinterpretation/wrapping/viewing of a verbatim value
with person.withAge(23),
person.with(age = 23)
returns a copy of an object in which the value of a field has been replaced with the argument value