xyz Don't see how lambdas make code messy.
because you are writing a function horizontally on an indentation language, it breaks the style and it's difficult to tell where the function begins and where it ends.
They are (arguably) ok in languages with semicolons and brackets, but not in gdscript where we use end-of-lines to break code.
Maybe I confused "lambdas" from other languages with how they work in gdscript. What I meant was, functions written horizontally or as parameters of another function.
In the gdscript style guide there are some rules that would be broken by the usage of lambdas inside parentheses:
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_styleguide.html
Line length¶
Keep individual lines of code under 100 characters.
If you can, try to keep lines under 80 characters. This helps to read the code on small displays and with two scripts opened side-by-side in an external text editor. For example, when looking at a differential revision.
One statement per line¶
Never combine multiple statements on a single line. No, C programmers, not even with a single line conditional statement.
Format multiline statements for readability¶
When you have particularly long if statements or nested ternary expressions, wrapping them over multiple lines improves readability. Since continuation lines are still part of the same expression, 2 indent levels should be used instead of one.
GDScript allows wrapping statements using multiple lines using parentheses or backslashes. Parentheses are favored in this style guide since they make for easier refactoring. With backslashes, you have to ensure that the last line never contains a backslash at the end. With parentheses, you don't have to worry about the last line having a backslash at the end.
When wrapping a conditional expression over multiple lines, the and/or keywords should be placed at the beginning of the line continuation, not at the end of the previous line.
this line has 101 characters, I counted them, but I could tell from a glance that it begins to get too long:
button_element.connect("pressed", func(): self._OnScienceDescription_pressed(scienceid_element.text))
It would probably look cleaner if the lambda is defined beforehand:
var lambda = func():
self._OnScienceDescription_pressed(scienceid_element.text)
button_element.pressed.connect(lambda)
but the function _OnScienceDescription_pressed can itself be passed as a callable without the need to define a lambda:
button_element.pressed.connect(_OnScienceDescriptor_pressed.bind(scienceid_element.text))