if
statement, the else
branch is optional, whereas in if
expression, else
branch is always required even if it is just an empty value..
',
'-
',
'_
'.
And variable names , like any other names, are case-sensitive.{
... }
establish a new statement block.Expression Type | Syntax | Remarks |
---|---|---|
if expression | if
(cond-expr)
then expr |
The else
branch is
always required, even if it is an empty
value; |
for expression | for
(var)
as type
in expr |
In this beta release,
you can declare only one variable in a for
expression. |
foreach expression | foreach
(expr)
order by expr
ascending|descending |
This is a simplified
version of for
statement. You can use function current()
to access the
current item that is being processed within the expression body. |
let expression | let var
as type
= expr |
Note that the value
initialization operator is '= ',
not ':= '
as in XQuery. In this beta release, you can only declare one variable
in a let
expression. |
with expression | with
(cond-expr) |
with
expression checks if cond-expr
is singular. If so, it is established as the current item, and the
expression body is evaluated; otherwise, it returns empty . |
switch expression | switch
(expr) |
The switch
expression is more like the switch statement in C/C++ and Java, but it
never falls through in the case
clause. And the default
clause is always required, even
if it is an empty
value. |
Statement Type | Syntax | Remarks |
---|---|---|
if statement | if
(cond-expr)
{ statements; } |
The else
branch is optional. |
for statement | for
(var)
as type
in expr
where expr ascending|descending
|
In this beta release,
you can declare only one variable in a for
statement. |
foreach statement | foreach
(expr) ascending|descending
|
This is a simplified
version of for
statement. You can use function current()
to access the
current item that is being processed within the statement body. |
let statement | let var
as type
= expr;
|
The scope of the
variable is from after this let
statement to the end of the block surrounding this statement.
In
this beta release, you can only declare one variable
in a let
expression. |
with statement | with
(cond-expr)
{ statements; } |
with
statement checks if cond-expr
is singular. If so, it is established as the current item, and the
statement body is evaluated; otherwise, the statement body is skipped. |
switch statement | switch
(expr)
{
|
In
the switch
statement, it
never falls through in the case
clause. And the default
clause is optional. |
put statement | put (qname
=
value) { statements; } |
This is a special statement in Candle that works like the tunneled parameter in XSLT. |
to get the value pushed by the put statement | context::qname |
A special prefix context::
is put in front of the qname of pushed value. |
statement causes the value
to be pushed onto a special stack with the static qname
as the key.
Functions inside the
statement body can then get the value
from this special
stack using the same qname
as the key. The value
is popped out from the stack at the
end of the statement execution. Put statements can
be nested, and items on the stack can have same qname
as
the key, with the inner most one occludes the outer ones. Put
statement saves you the trouble of passing some parameters along, when
you have many deeply nested functions. Here's an example:Statement Type | Syntax | Remarks |
---|---|---|
set statement | set var
= value; |
In functions, you cannot
change the value of a variable once
it is initialized. In procedural routines, you can do so. But you
should follow the good practice of functional programming, and only use
set
statement in side while
loop to
change the value of the looping variable.
|
while statement | while
(expr)
{ statements;
} |
The good-old while
statement in every
procedural languages. |
continue statement | continue; |
This continue statement
can only be used in the while
statement. |
break statement | break;
|
This
break statement can only be used in the while
statement. |
return statement | return; |
If a method does not
have return value, then return;
should be used; otherwise, return
expr; should be used.
|