Godot-proposals: Add static typing hint "Variant" to improve code clarity

Created on 20 Mar 2020  路  4Comments  路  Source: godotengine/godot-proposals

Describe the project you are working on:
Proprietary information

Describe the problem or limitation you are having in your project:
Inconsistent static typing hints in GDScript, which do not aid the programmer to
identify variant type variables, when their use is required.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Add static typing hint called "Variant". Adding this would make the static typing hints uniform, so
I could add hints to all variables and clearly see, where I need to take into account Variants, when
debugging my code.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

func myfunc(myparam:Variant) -> Variant:
   var myvar:Variant = myparam
   return myvar

If this enhancement will not be used often, can it be worked around with a few lines of script?:
No

Is there a reason why this should be core and not an add-on in the asset library?:
Cause static typing hints are hardcoded into engine source code.

gdscript

Most helpful comment

All 4 comments

This would be a great addition to static typing.

@FaultyFunctions Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.

This is now supported in master since the new GDScript was merged, closing.

image

Was this page helpful?
0 / 5 - 0 ratings