Types and data
KataScript uses three declarations for different jobs: kind combines named fields, enum defines alternatives, and type describes an interface. All produce first-class type values.
Products with kind
Section titled “Products with kind”kind Point { x: Int, y: Int }
let point = Point { x: 3, y: 4 }print(point.x)point.y = 8print(point.y)Construction supplies every declared field by name. There are no default fields or positional constructors. Field values are checked against their declared types.
Use direct named receivers for mutation. Nested writes such as parent.child.x = 1 are not supported.
Alternatives with enum
Section titled “Alternatives with enum”enum Direction { North, South, East, West }enum Message { Text(Str), Quit }
let message = Message.Text("hello")match message { Text(value) -> print(value), Quit() -> print("goodbye"),}A variant can carry positional values or carry nothing. Construct a unit variant as Message.Quit; match it with parentheses as Quit(). A bare identifier in a pattern binds a name.
Generic types
Section titled “Generic types”kind Pair[A, B] { first: A, second: B }
let item = Pair[Int, Str] { first: 42, second: "answer" }print(item.second)
let present = Opt[Int].Val(42)let absent = Opt[Int].Nonprint(present.unwrap_or(0))print(absent.unwrap_or(0))Write type arguments explicitly. Opt.Val(42) does not infer Opt[Int]. Generic definitions can express reusable shapes, but parameter constraints and complete generic-interface validation are not available.
A concrete generic field inside a non-generic definition currently triggers a host bug. Avoid declarations such as kind Holder { value: Opt[Int] }; see language status.
Tuples
Section titled “Tuples”let item = ("Ada", 42)print(item.0)print(item.1)print(typeof(item)) # Tup[Str, Int]() is the empty tuple. (value,) is a one-element tuple; (value) only groups an expression. Tuple elements may have different types and support destructuring.
Type values
Section titled “Type values”typeof(value) returns a type value, and type values can be printed, compared, or bound to names. Type identity is tracked by the interpreter’s registry, not by comparing display names.
Continue with methods and interfaces to attach behavior to your types.