Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Specify when semicolons are necessary

...

The expression on the right is evaluated and its value is bound to the variable on the left. The right-hand side can be any valid expression

Declarations Function declarations are separated by semicolons.

The following example shows two variables, x and y, being declared:

Code Block
languagejavascript
themeConfluence
languagejavascript
x = 5;
y = event:url.extract(#http://(\[^/?]+)#)

...

KRL variable declarations are not variable assignments. Neither can KRL expressions cause persistent side effects. For example, the second declaration in the following prelude does not change the value to which x is bound. Rather, it results in two bindings of x, one of which is hidden (shadowed) by the other:

Code Block
languagejavascript
themeConfluencelanguagejavascript
x = 5;
x = x + 6;

Developers should avoid treating declarations as assignments because they will invariably be surprised by the resulting semantics in subtle ways.