Keywords · INPUT

INPUT

An INPUT is a typed parameter a function receives from its caller.

Format

The grammar of a single INPUT line:

INPUT ::= "INPUT" [ "BINDING" ] type identifier [ "=" constantExpression ]
type ::= name [ "(" type { " " type } ")" ]
constantExpression ::= constant | name { " " constant }
constant ::= string | integer | number
name ::= identifier { "." identifier }
identifier ::= letter { letter | digit }
An INPUT keyword is followed by an optional BINDING modifier, then the parameter's type and name. It may end with an optional = and a constant expression — a constant, or a type constructor applied to constants — giving the parameter a default value.

Usage

An INPUT keyword can live inside FUNCTION and HOLE keywords.

Inside a FUNCTION

A parameter of the function, declared before the body; the caller supplies its value on every call.

FUNCTION Ui.Form.Result FormSubmit
  INPUT Text endpointName
  INPUT BINDING Ui.Form.Result formData
A function taking a forward input and a two-way BINDING input.

The first input is forward (read-only); the second carries the BINDING modifier, so the function both reads formData and writes back to it. The same inputs stand whether the function has a Program body or per-target NATIVE bodies — they are the values each native body receives.

Inside a HOLE

One of the arguments the callback block receives each time the function invokes the hole.

FUNCTION Ui.Form.Result FormSubmit
  HOLE Text renderField
    INPUT Text fieldLabel
A hole whose indented INPUT is the argument its block receives.

The renderField hole's indented INPUT, fieldLabel, is the argument the caller's block is given each time the function invokes it — a plain forward input.

Can Contain

An INPUT is a leaf: a type and a name, and no keyword nested inside. It opens no indented lines of its own. (Inside a HOLE, the indented lines are the hole's own inputs, not the input's.)

Modifiers

One optional modifier may sit before the type:

BINDING

Written before the type, BINDING switches the parameter from forward (read-only) to two-way (read and write), so the function can write back through it — usually into a caller's STATE. It is a modifier, not a keyword of its own: it has no body and adds no line of its own, it only changes how the input behaves.

Targets

The same example, rendered to each target.

JavaScript

// inputs are plain parameters; BINDING ones are read AND written
function FormSubmit(endpointName, formData) {
  // ... reads endpointName, reads and writes formData
}

TypeScript

function FormSubmit(endpointName: string, formData: Ui.Form.Result): ReactiveValue<Ui.Form.Result> {
  ReactiveSecurity.Gettable<string>(endpointName);
  ReactiveSecurity.Settable<Ui.Form.Result>(formData);   // BINDING: two-way
}

Dart

static ReactiveValue<Ui_Form_Result> FormSubmit(String endpointName, Ui_Form_Result formData) {
  ReactiveSecurity.Gettable<String>(endpointName);
  ReactiveSecurity.Settable<Ui_Form_Result>(formData);   // BINDING: two-way
}

Swift

public static func FormSubmit(_ endpointName: String, _ formData: Ui.Form.Result) -> ReactiveValue<Ui.Form.Result> {
  ReactiveSecurity.Gettable<String>(endpointName)
  ReactiveSecurity.Settable<Ui.Form.Result>(formData)    // BINDING: two-way
}

Go

func (Ui_FormStatic) FormSubmit(endpointName string, formData Ui_Form_Result) ReactiveValue[Ui_Form_Result] {
  ReactiveSecurity.Gettable[string](endpointName)
  ReactiveSecurity.Settable[Ui_Form_Result](formData)    // BINDING: two-way
}

Rust

pub fn FormSubmit(endpointName: String, formData: ui::form::Result) -> ReactiveValue<ui::form::Result> {
  ReactiveSecurity::gettable::<String>(&endpointName);
  ReactiveSecurity::settable::<ui::form::Result>(&formData); // BINDING: two-way
}

Zig

pub fn FormSubmit(endpointName: []const u8, formData: ui.form.Result) ReactiveValue(ui.form.Result) {
  ReactiveSecurity.gettable([]const u8, endpointName);
  ReactiveSecurity.settable(ui.form.Result, formData);    // BINDING: two-way
}

JSON

["F", "FormSubmit", [], [
  ["endpointName", "Text"],
  ["formData", "BINDING", "Ui.Form.Result"]
], [ /* body */ ]]

Related

A callback parameter is a HOLE instead; the write-back a BINDING input enables is performed with REVERSE. Inputs belong to a FUNCTION, and often carry record or union TYPE values. Back to the language.