You can define the return type of functions, like func foo() -> int: return 42. And I think I read that this actually helps the GDScript compiler/runtime to generate slightly better code. In addition to other benefits that static typing provides but I am just looking at performance here.

I always define the return type of functions that actually return something but I don't define it for functions that return nothing. So basically at the moment I would write:

func return_fancy_value() -> int:
    return 42

func do_nothing():
    pass

But I wonder if it actually helps to declare those void functions with -> void. Does anyone know if this has any positive effect on performance?

14 days later

And to answer my own question: I just benchmarked it and it completely doesn't matter if we define a function as func foo(): or func foo() -> void:. Tested it with 4.1.2 and 4.2.-dev6.

    Toxe
    it matters to me because writing -> var_type makes it look like i know what i'm doing, but most importantly, i think it looks cool. i never write a function without it.

    in real life seriousness for real life programmers, it makes it pretty clear why the function exists.
    personally, i exclusively static type because I'm:

    1. paranoid of magicking variables into a different type.
    2. deficient in attention, and comments are too clunky.

    in more seriousness, i wondered if defining functions that way made a performance difference.
    now i know.