There are two reasons that I am aware that are arguments for not allowing user-defined functions to be called from watches nor evaluator. Both are to protect the user from unwanted effects. The decision here is really more safety vs. more power.
Firstly, invoking performance-heavy functions in watches can make the FPS plummet really easily. If the function contains infinite loop, it can even make the game crash. The infinite loop case can be handled, though.
Secondly, calling unknown functions can have unwanted side effects on game state. Generally speaking, any functions that change state should not be invoked from the debugger. There's no way of ensuring this, though. I am not sure whether GDScript is planned to have a concept of const methods. Another alternative would be to use annotations if they are ever implemented.
For me, the second argument is strong enough to disallow user-defined functions for now. If the GDScript will allow either of the concepts I mentioned I'd revisit this decision.
What are your thoughts on this @jahd2602? Do you see a use case for evaluating user-defined functions? If so, a compromise would be to disallow it by default but have an option in Editor Settings to allow it. This will at least protect the less experienced users and give the power to those who need it.
There are two reasons that I am aware that are arguments for not allowing user-defined functions to be called from watches nor evaluator. Both are to protect the user from unwanted effects. The decision here is really more safety vs. more power.
Firstly, invoking performance-heavy functions in watches can make the FPS plummet really easily. If the function contains infinite loop, it can even make the game crash. The infinite loop case can be handled, though.
Secondly, calling unknown functions can have unwanted side effects on game state. Generally speaking, any functions that change state should not be invoked from the debugger. There's no way of ensuring this, though. I am not sure whether GDScript is planned to have a concept of
constmethods. Another alternative would be to use annotations if they are ever implemented.For me, the second argument is strong enough to disallow user-defined functions for now. If the GDScript will allow either of the concepts I mentioned I'd revisit this decision.
What are your thoughts on this @jahd2602? Do you see a use case for evaluating user-defined functions? If so, a compromise would be to disallow it by default but have an option in Editor Settings to allow it. This will at least protect the less experienced users and give the power to those who need it.