Open therontarigo opened 2 weeks ago
Inlining is not that simple. There are many potential issues to tackle.
A difficulty is to handle variables correctly, even with shadowing (renaming might be required).
If the function return value is used, it can be difficult to inline it (and do side-effects in the correct order).
int f() {
for (...) { ... }
return ...;
}
void main() {
int a = g() + f();
}
To inline f()
here, you might need to introduce new local variables and split the line.
I reopened #469 , as it is the only one with a chance of being easy to implement.
I was thinking that it is an unnecessary restriction in the case that the function is called in a simple assignment statement:
float x = func(...);
However, considering more carefully what the resulting minified code would be, there's no case for that where return-by-inout wouldn't work just as well. So that's one more reason to abandon this and focus on #469 .
It should (in some circumstances) be possible to inline a function that follows these rules:
void
type, or ends in an unconditional return statement.return
statements.