Calling functions

Functions might be called directly by their name, like:

print("Hi")

When calling a function with multiple parameters, it isn't needed for you to separate these arguments with commas, making the following calls valid:

my_function(1, null, "With commas")
my_function(1 null "No commas!")

If you are using an implementation with multiple modules, two modules can have the same function for a name, like 'sum' function in both a 'math' and an 'my_nums' module, to disambiguate from them, you can precede the module's name to the function, like:

math/sum("1 2 3")    //Calls 'sum' from the 'math'    module
my_nums/sum("1 2 3") //Calls 'sum' from the 'my_nums' module


*Note that Moon Script comes with very few functions, currently just having 'print' and 'println' functions to print one value.

Optimizations

Some functions are constant, meaning that when its arguments are known at compile time, their result will be calculated at compile time to prevent needlessly calculating the same value over each execution:

Input Moon Script Optimization
a = 5
b = 10
sum = add(a b)
return sum

Given the custom function named add is constant:

return 15