Closures around lexical scope #10280
ianstranathan
started this conversation in
Scripting
Replies: 1 comment 1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, hopefully I'm posting this in the right place.
Firstly, Godot is awesome and I'm happy to be using it!
Discussion point:
I prefer a more functional style of coding (I know, it's a fools errand as godot is very OOP but...) and sometimes I like
hiding simple things in a function instead of having too many member variables to keep track of (reduces complexity overhead imo)
This seems to be only possible for heap allocated data structures unfortunately (Array, Dict, even Vector2)
A contrived example:
The closure/ lexical scope isn't saved; the returned _is_pressed is always false.
Godot has higher order functions and scope around heap allocated data structures, would it be hard to add proper lexical scope?
Any help or comments is appreciated.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions