Compile-time GML function execution (functions that are exposed to Catspeak) #117
Labels
enhancement
New feature or request
low priority
Not important
optimisation
Related to optimising Catspeak code
What is your feature request?
It'd be nice if we could have certain functions automatically call and create a value during the compiler stage, if assuming they wre compile time runnable.
A good example is something like this.
Right now the compiler is doing
program -> call -> fetch argument values -> call function -> return result
But it could easily be
program -> return value
. (Obviously, concating in the first place is better)Please describe in detail how you expect this new feature to behave.
The compiler should be able to evaluate and determine if a function (Catspeak or GML) is a compile time function, and all of it's arguments (whether valid compile-time function or value) also meet the criteria.
This should be achieved by applying a list of conditions that the compiler can use to check and evaluate each argument (whether a compile-time function or value). Compile-time functions as arguments are daisy-chainable and will check each function call to ensure that they are too compile-time callable.
If it's not a value that is defined (such as a global), is not a compile-time function or a value (such as
2
or"Hello World"
), the compiler will treat it as a normal function call instead.Such a great example is
In this case,
string_concat
,string
andreal
are all compile-time functions. Butget_timer
is not.So the compiler will have it as
program -> call -> fetch argument values -> call function -> return result
.But applying
get_timer
with a compile-time flag as well, will collapse the whole program down toprogram -> return value
. In this case, the value ofget_timer
at the time. (It will never change once compiled)Bonus: I already written it in my own GML interpreter project, that uses Catspeak as the backbone. All handled via the interface + compiler.
The text was updated successfully, but these errors were encountered: