@ operator

From MiniScript Wiki
Jump to navigation Jump to search

Normally in MiniScript, whenever a variable a used in an expression, if it refers to a function, that function is automatically invoked. The @ operator suppresses this invocation, allowing you to work with a function reference without invoking it.

Example

Try the following at any interactive MiniScript REPL:

f = rnd    // makes f contain the result of calling [[rnd]]
f          // prints that result
f          // prints that SAME result again (f is just a number
f = @rnd   // makes f refer to the [[rnd]] function
f          // invokes f, and prints a random number
f          // invokes f again, printing a DIFFERENT result