Keywords · CALL

CALL

A CALL is a function called on its own line. Unlike every other keyword it has no keyword word in front of it — a line that is just a function name and its arguments is a call. It is how a body makes something happen.

Format

The grammar of a call line: a function name, then its arguments.

CALL ::= name { " " argument }
argument ::= name | constant
name ::= identifier { "." identifier }
A dotted function name followed by zero or more arguments — each a reference or an inline constant. A block argument that fills a HOLE is written on the indented lines below.

In the canonical form a call is a FunctionCall node, tagged CALL: its functionName, any typeArguments, and its arguments.

Usage

A CALL is a body command: it can stand on its own line anywhere a body runs — the Root run body, a FUNCTION body, a REVERSE body, or the body of a WITH.

At the Root

A call on its own line at the Root is the program's entry point.

App.Start "ready"
A bare call in the Root run body.

Inside a FUNCTION

An effect call inside a function body, run for what it does rather than a value it binds.

FUNCTION Log
  INPUT Text line
  Console.Write line
A call statement inside a function body.

Inside a REVERSE

A call in a reverse body, doing work before the write-back.

REVERSE Text draft
  Analytics.Track "edited"
A call inside a reverse body.

Can Contain

A call's arguments follow it on the same line, or as an indented block when one fills a hole.

Reference arguments

A name in scope, passed straight through.

Text.Append greeting name
Two references passed as arguments.

Constant arguments

A literal written inline at the call.

Console.Write "done"
A text constant passed inline.

A block filling a HOLE

When the function has a hole, the block that fills it is written on the indented lines below the call.

List.Each rows
  Console.Write row
A call whose hole is filled by the indented block.

Targets

The same call, rendered to each target.

JavaScript

App.Start(message);

JSON

["CALL", "App.Start", [], [["reference", "message"]]]

Related

A CALL runs in the ROOT run body or a FUNCTION, REVERSE or WITH body. A call whose result is bound to a name is a LET instead. Its canonical shape is the FunctionCall node. Back to the language.