XML에서
XML에서는 같은 타입이 <type>의 속성과 요소로 표현됩니다:
<type name="Username" with="handle" max="16" not="@admin, @root">
<validate test="not $value.name->starts_with('_')" message="A username cannot start with _" />
</type>
<type name="Admin" with="User, Auditable">
<field name="level" type="int" default="1" />
</type>
<let name="who" type="Username" value="@joan" />
<type name="Point">
<construct>
<field name="x" type="number" />
<set name="doubled" value="$x * 2" />
</construct>
<field name="doubled" type="number" />
</type>type Username with [handle] {
max: 16
not: [@admin, @root]
validate: not $value.name->starts_with('_'), 'A username cannot start with _'
}
type Admin with [User, Auditable] {
level: int = 1
}
$who: Username = @joan
type Point {
construct({ x: number }) {
.doubled = .x * 2
}
doubled: number
}<construct>에는 호출자가 전달할 수 있는 필드가 담기고, 그다음에 실행할 문장이 이어집니다. private 멤버에는 <field> 또는 <fn>에 private="yes"가 붙습니다. kscript convert는 두 형식 중 하나를 다른 형식으로 바꿔 줍니다.