Tour: Calls and Assignments

You call a subject by giving a list of flow arguments, a list of blocks, or both. You can give each argument either as flow argument or block. This generalizes over LaTeX's commands and environments.

You can call functions and certain types. Such calls are call expressions and will evaluate their arguments during evaluation. Calling a Record type will construct a record value, the arguments go into are the type's fields.

You can also call keywords. In Nyarna, keywords are symbols just like functions and types.

A special kind of keywords are prototypes which, when called, generate types. For example, \Record is a prototype that when called generates a record type with the given fields.

Assignments are structurally similar to calls. They start with a “:=” after the subject, followed by either an argument list or a block list, which must contain exactly one unnamed argument. Assignable subjects are variables, fields of variables, as well as List and HashMap accessors.

Details

A call is a command structure that has a subject succeeded by an argument list, a block list, or both in that order. Calls can be chained with other calls and accesses. The call subject must define a list of parameters. Each flow argument and block will be associated with one of those parameters. Each parameter's argument may be given as either flow argument or block. The call subject defines the order and name of parameters, and which parameter consumes the primary block.

Calling a keyword is syntactically the same as a call expression, however while the call expression is an expression, the keyword call generates one. For example, a call to \if will generate an if-expression. This expression will, when evaluated, check its condition value and then either evaluate the then or the else branch. If \if was a function, calling it would evaluate both branches which is not desirable.