wiki Simple static assignment

Simple static assignment

From wiki

The triple script dialect restricts the number of programming constructs that may appear in a module's top-level scope. Aside from definition of the exported class (or function, etc.), the only other constructs that may appear are simple static assignments.

A class may benefit from the definition of some enum-like values, for example. Suppose we had a LineWriter class and we wanted to be able to discriminate between DOS-style line separators and Unix-style newlines.

export class LineWriter {
  /* ... class implementation omitted for brevity ... */

LineWriter.TYPE_CRLF = 0;
LineWriter.TYPE_LF = 1;

The definition of LineWriter.TYPE_CRLF and LineWriter.TYPE_LF is valid here, because it's a numeric literal constant, which is one of the permissible forms of static assignment.

NB: Not to be confused with SSA form in compiler IR.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.