Functions

Visual FLX language is based under the hood on FLX Lisp. Lisp is a functional programming language and so is FLX Lisp. FLX provide an extensive set of built-in functions including the functions that are used to build applet UIs in declarative way. Beside built-in functions FLX provides macro functions that can be used, for instance, to define new custom functions.

Some examples of FLX functions:

  1. A built-in function called substring which takes two arguments, String and Int and returns a substring of the given string starting from the specified index.
  2. A user defined function with name sum. This function is defined to have two arguments x and y. The body of the function is implemented using addition (+) function which is also a built-in function.
  3. Invocation of the defined function sum with parameters 1 and 2.
  4. An anonymous user defined function without a function name. Anonymous functions can be used like closures.

Macro Functions

Macro functions are special functions that used as higher level functions. Currently FLX language defines the following macro functions:

  1. Block: Contains nested code. Blocks are not scoped which means, that functions and variables defined inside a block are also visible and accessible outside a block.
  2. callback: A callback can be used to implement closures since they define code and input parameters for the code.
  3. fun: A macro function that is used to define new functions.
  4. val: A macro that defines an immutable value i.e. constant. Similar to Kotlin’s val definition.
  5. var: A macro that defines a mutable variable. Similar to Kotlin’s var definition.
  6. eval and quote: Macro functions from Lisp. Function eval evaluates the value of the given form whereas quote does not evaluate its parameter.
  7. parse: A function that parses the the given literal expression and converts it to a form.