Targets · Swift · Keywords

Keywords

How each of Program's keywords is rendered into Swift.

Contents

How a Program becomes Swift, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

Program keywords in Swift

Each of Program's keywords maps to idiomatic Swift. Names stay nested through caseless enums (see the example); the reactive keywords are calls into the runtime. Follow a keyword's own page for the full rendering and the other targets.

KeywordRendered Swift
MODULEA nested caseless enumenum Ui { enum Button { enum Integer { … } } }.
TYPEA record becomes public struct Point { public let x: Double; public let y: Double; public init(_ x: Double, _ y: Double) { … } }; a union becomes public enum Shape { case circle(Circle); case rect(Rect) }.
FUNCTIONpublic static func Name(…) -> ReactiveValue<T> { … return … }.
NATIVEA public static func whose body is the swift NATIVE string.
INPUTA parameter; a BINDING input is read and written.
HOLEA trailing closure parameter.
LETlet name = ….
STATElet name = Reactive.State<T>(value).
REVERSEA write-back whose closing SET is Reactive.Set(state, value).
WITHModule.With(Name.self, Replacement.self) { … }.

See JavaScript keywords for the per-keyword detail and the modifiers; Swift differs in idiom (nested enums, struct/enum types) but the mapping is the same.