Keywords · SET

SET

A SET is the closing line of a REVERSE that writes a value into an outer STATE.

Format

The grammar of a single SET line:

SET ::= "SET" identifier "=" expression
expression ::= name { " " argument }
argument ::= name | constant
constant ::= string | integer | number
name ::= identifier { "." identifier }
identifier ::= letter { letter | digit }
A SET keyword is followed by the outer STATE to write and the value to put there after the =.

Usage

A SET keyword can only live inside a REVERSE keyword.

Inside a REVERSE

Writes the value the reverse's forward body prepared back into the outer state it names.

REVERSE Logic.Maybe incrementFlag
  LET Maths.Integer currentCount = Maths.Integer.Increment refreshCountState
  SET refreshCountState = currentCount
A reverse whose closing SET writes the new count back into outer state.

A SET ends a reverse: after the forward body has prepared a value, the final SET is where that value is written back into outer state.

Can Contain

Nothing. SET is a leaf: a state name, =, and a value. It has no body and opens no indented lines — it only pushes its value into the outer state it names.

Targets

A reverse rendered to each target; the closing SET lowers to the reactive setter Reactive.Set(state, value) (Reactive::set in Rust, Reactive.set in Zig) on the last line of each block.

JavaScript

// a write-back: runs when submissionReverse is written
function submissionReverse() {
  var httpResponse = Network.Web.Client.Post(url, optionalBody, headers);
  var result = Api.Client.ParseFormResult(httpResponse);
  Reactive.Set(formDataState, result);   // SET pushes into outer state
}

TypeScript

Reactive.Reverse(submissionReverse, () => {
  const httpResponse = Network.Web.Client.Post(url, optionalBody, headers);
  const result = Api.Client.ParseFormResult(httpResponse);
  Reactive.Set(formDataState, result);   // SET pushes into outer state
});

Dart

Reactive.Reverse(submissionReverse, () {
  final httpResponse = Network_Web_Client.Post(url, optionalBody, headers);
  final result = Api_Client.ParseFormResult(httpResponse);
  Reactive.Set(formDataState, result);   // SET
});

Swift

Reactive.Reverse(submissionReverse) {
  let httpResponse = Network.Web.Client.Post(url, optionalBody, headers)
  let result = Api.Client.ParseFormResult(httpResponse)
  Reactive.Set(formDataState, result)    // SET
}

Go

Reactive.Reverse(submissionReverse, func() {
  httpResponse := Network_Web_Client.Post(url, optionalBody, headers)
  result := Api_Client.ParseFormResult(httpResponse)
  Reactive.Set(formDataState, result)    // SET
})

Rust

Reactive::reverse(submission_reverse, Box::new(move || {
  let http_response = network::web::client::Post(url, optional_body, headers);
  let result = api::client::ParseFormResult(http_response);
  Reactive::set(form_data_state, result);  // SET
}));

Zig

Reactive.reverse(submission_reverse, struct { pub fn run() void {
  const http_response = network.web.client.post(url, optional_body, headers);
  const result = api.client.parse_form_result(http_response);
  Reactive.set(form_data_state, result);   // SET
} }.run);

JSON

["S", "submissionReverse", "Ui.Form.Result", [
  ["=", "httpResponse", "Network.Web.Response", ["Network.Web.Client.Post", [], ["url", "optionalBody", "headers"]]],
  ["=", "result", "Ui.Form.Result", ["Api.Client.ParseFormResult", [], ["httpResponse"]]],
  [">", "SET", [], ["formDataState", "result"]]
]]

Related

SET closes a REVERSE and writes into a STATE; the value it writes usually comes from LET bindings in the reverse body. The write-back a SET performs is exactly what a two-way BINDING input triggers. Back to the language.