{
<statements> }
(
[<param-expression>[ ,
<param-expression>[ ,
... <param-expression>]]] )
Param-expression is either a normal expression or a spread operator ...
<iterable> where iterable is an array, tuple or generator instance. Iterable expands to sequence of arguments.
if
(
<expression> )
<statement> [ else
<statement> ]while
[ :
name ] (
<expression> )
<statement>do
[ :
label ] <statement> while
(
<expression> )
for
[ :
label ] (
<init-expression> | var
<name-with-initialization> ;
[<condition-expression>] ;
[<inc-expression>] )
<statement>for
[ :
label ] (
[ var
] <name> in
<expression> )
<statement> [ otherwise
<statement> ]for
[ :
label ] (
[ var
] <name-list> in
<expression> )
<statement> [ otherwise
<statement> ],
and enclosed by (
)
parentheses.for( var (k,v) in obj ) stdout.printf("k=%s,v=%v,", k, v);
- prints names and values of each property of the object.for( var (i,v) in arr ) stdout.printf("i=%d,v=%v,", i, v);
- prints indexes and values of each member of the array.switch
(
<selector-expression>)
The switch statement allows to select one of the many blocks of code for execution:
switch
(
<selector-expression>)
{
case
<case-expression>:
<statements> [...]like
<template-expression>:
<statements> [...]instanceof
<class-name>:
<statements> [...]in
<collection>:
<statements> [...]default:
<statement>}
When the result of <case-expression> equals the value of the <selector-expression>, the corresponding <statements> are executed. If <template-expression> matches the selector-expression the corresponding <statements> are executed.
If there is no matching <case-expression> or <template-expression>, the statements marked by the default:
label get executed (if present).
break [label] ;
for:outer ( var row in rows ) for:x ( var cell in row ) if ( cell == current ) break outer;
continue [label] ;
var
<name-or-name-list> [ =
<init-expression>] [ ,
<name> [= <init-expression>] ... ] ;
{
... }
) establish variable scopes in the language. (Note: In JavaScript, the scope is established only by the body of a function).(
and )
parentheses and separated by the comma ,
var (a,b,c) = 1;
- declares variables a,b,c and assigns value '1' to them.var (a,b,c) = (1,2,3);
- equivalent of var a = 1, b = 2, c = 3;
return
[ <expression> | <expression-list> ] ;
function rect() { return (10,10,100,100); }
var (x,y,width,height) = rect(); // x and y get '10' and width and height get '100' values.
const
<name> = <init-expression> [ ,
<name> = <init-expression> ... ] ;
try
<statement> catch
(
<variable-name> )
<catch-statement> finally
<finally-statement>with
(
<expression:object> )
<statement>await
<promise-returning-expression> ;yield
<expression>;include
<string-expression> | <stream-expression> | <bytes-expression> ;
import
...Import individual features (functions, variables, constants, classes and namespaces):
import { name } from "module file path"; // imports only name entity import { name1, name2 } from "module file path"; // imports name1 and name2 entities
Import default exported entity:
import name from "module file path"; // export default entity as name
Import all of a module's exports as a module object:
import * as name from "module file path";
Import exports with local aliases:
import { theirName as name } from "module file path";
Import a module for side effects only:
import "module file path";
export [default] ...
The export is a modifier that can appear before function
, class
, namespace
, var
or const
declarations inside modules to mark entities exported from modules.
assert
<test-expression> [ :
<space-separated-list-of-expressions> ] ;
The assert statement allows you to test assumptions about your program. When the <test-expression> evaluates to false at runtime, an error is thrown with the source text of the <test-expression> and optional list of expressions.
Note: with no debugger attached, this statement has no effect (NOP - empty instruction);
debug break;
debug namespace;
debug stacktrace;
debug [log | info | warning | alert] :
<space-separated-list-of-expressions> ;
debug [log | info | warning | alert] (
<stringizer-function-parameters> )
Log output: renders results of evaluation of expressions to the debug output. Second format supports stringizer parameters like:
debug info ( object data {obj} );
Note: with no debugger attached, this statement has no effect (NOP - empty instruction);
;