Types
Spine type syntax describes either a named reference (possibly with type arguments) or a tuple of types.
Reference types
[ '.' ] identifier ( '.' identifier )* [ '<' Type ( ',' Type )* '>' ]
- Leading
.: the name is absolute (resolved from the root namespace). Without it, the name is resolved using the current namespace and imports. - Generics: angle brackets supply type arguments, e.g.
List<String>,JoinTrigger<String, Item>.
Qualified names use . between segments, e.g. com.dataspine.json.Value.
Tuple types
'(' Type ( ',' Type )+ ','? ')'
Two or more types in parentheses form a tuple type. A single type in parentheses in an expression is grouping; in type positions, tuple types require at least two members.
Version suffixes on names
An identifier may include @ and digits as part of the name (e.g. struct Foo@1, field prop@1: Type@2).
void
void is allowed in type positions where the language defines it.
Standard library
The Dataspine CLI loads the bundled standard library in the com.dataspine namespace (version 1) by default. You can attach more type definitions with --lib when running check or compile. See Runtime library.
Annotations on fields
Struct fields may be prefixed with annotations:
Struct Foo {
@AdminOnly(reference: something) secret: String,
}
Use @ followed by a type reference and optionally ( name: expr, ... ).