HipHop Core Expressions

Introduction

This document presents the HipHop core (sometime called "kernel") expressions, but the dynamic expressions which are described in Page Dynamic expressions. This document is a prerequisite to understand how Compound expressions are built using core expressions.

Synopsis

(nothing&)
(emit& event value*)
(pause&)
(if& condition then-expr else-expr?)
(suspend& condition expr+)
(seq& expr+)
(loop& expr+)
(par& expr+)
(trap& name expr+)
(exit& trap-name)
(local& (event*) expr+)
(atom& host-expr)")

Expressions

nothing&

(nothing&)

Does nothing, and terminates instantaneously.

emit&

(emit& event value*)
Argument Type Description
event <event> The event object to emit
value <host-expression> Optional values to emit, see Events

Emit the event event and terminates instantaneously. If one or several value are given, they will be evaluated and the resulting values are passed to the hiphop-event-compose*! methods detailed in Page Events.

pause&

(pause&)

Pauses the execution for the current reaction.

if&

(if& condition then-expr else-expr?)
Argument Type Description
condition <host-expression> A Boolean host expression
then-expr <expression> Then expression
else-expr <expression> Optional else expression

The if& conditional first evaluates condition. If the result of the evaluation is true, the then-expr expression is executed, otherwise the else-expr expression is executed.

The if& conditional terminates when the selected branch terminates.

If missing, the else-expr argument defaults to (nothing&).

suspend&

(suspend& condition expr+)
Argument Type Description
condition <host-expression> A Boolean host expression
expr <expression> The suspend body

suspend& starts executing is body at the first instant it receives control. If several body expressions are given, they will be executed as if they were enclosed in a seq& form.

At other instants, suspend& first evaluates condition. If the condition evaluates true, then the execution is suspended and the whole suspend& expression pauses. Otherwise, the body is resumed.

suspend& terminates (resp. exits) when its body terminates (resp. exits).

seq&

(seq& expr+)

seq& accepts any number of expressions, but expects at least one. Expressions may given as lists of expressions. The first expression is executed when seq& is executed for the first time. The next branch is instantaneously started when the previous branch terminates. If a branch pauses, seq& pauses. On resume, the branch that paused is resumed.

seq& terminates when the last branch terminates. seq& exits when a branch exits.

loop&

(loop& expr+)

loop& accepts several expressions as body. A loop& executes its body and restarts when its body terminates. Instantaneous loops are forbidden if the body terminates and restart twice in an instant, a runtime exception is raised, and the reaction is aborted.

loop& never terminates. It exits when its body exits.

If more than one expression are given as body, they will be enclosed in seq&.

par&

(par& expr+)

par& accepts the same type of arguments as seq&.

par& starts all its expressions at the instant par& starts. On resume, only the non-terminated branches are resumed.

par& terminates when all its branches terminates. It exists when all branches are either terminated, paused or exited..

trap&

(trap& name expr+)
Argument Type Description
name <symbol> A symbol naming the trap
expr <expression> The trap body

trap& binds syntactically name in its body. Each (exit& name) in its body will exit the current trap when executed (or the closest trap is several nested traps share the same name). Trap names can hide each other.

trap& terminates when its body terminates or exits with the current trap name. If the body exits with another name, trap& exits with that name.

If more than one expression are given as body, they will be enclosed in seq&.

exit&

(exit& trap-name)

exit& exits the trap named trap-name. If the named trap does not exist, an error is raised at compile time. If several traps have the same name, the exited trap will be the closest trap with that name in the execution stack.

local&

(local& (event*) expr+)

local& scopes event. By default, events have a global scope in expressions. local& resets the event states each time it is started, but not when resumed. A typical use of local& is within loops, to ensure an event is absent at the beginning of the loop& body.

A compile-time error is raised if an event referenced in a local& expression is used out of the local's body.

If more than one expression are given as body, they will be enclosed in seq&.

atom&

(atom& host-expr)

atom& executes a host-expression (see Host expressions) and terminates instantaneously.


Return to Top
Page last modified Sat May 25 09:56:47 2013.