You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
print(0)
print(0.0)
print(Vector3(0.0, 1.0, 1.2))
Currently, when printing floats in GDScript, the trailing .0 is excluded. The above prints would print out 0, 0, and Vector3(0, 1, 1.2). This means that the values being printed do not necessarily match the type used in GDScript, and when debugging it's hard to tell if the value 0 is an int or a float because they are identical.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Change the behavior so that floats are always printed as valid float literals. So, the above example would print 0, 0.0, and Vector3(0.0, 1.0, 1.2).
This seems like a fairly straight-forward change, but it has a lot of nuance and wide-reaching implications for all areas of the engine, so it needs to be done with care and a lot of testing. A lot of places will need adjustment including the GDScript tests and the C# bindings generator. One of the points of nuance is that different types have different precision, which needs to be taken into account when printing.
This doesn't affect ABI compatibility, so it could be done in a 4.x release, but also it does significantly change behavior so it could be seen as a breaking change.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Describe the project you are working on
This isn't related to a specific project.
Describe the problem or limitation you are having in your project
Currently, when printing floats in GDScript, the trailing
.0
is excluded. The above prints would print out0
,0
, andVector3(0, 1, 1.2)
. This means that the values being printed do not necessarily match the type used in GDScript, and when debugging it's hard to tell if the value0
is an int or a float because they are identical.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Change the behavior so that floats are always printed as valid float literals. So, the above example would print
0
,0.0
, andVector3(0.0, 1.0, 1.2)
.This seems like a fairly straight-forward change, but it has a lot of nuance and wide-reaching implications for all areas of the engine, so it needs to be done with care and a lot of testing. A lot of places will need adjustment including the GDScript tests and the C# bindings generator. One of the points of nuance is that different types have different precision, which needs to be taken into account when printing.
This doesn't affect ABI compatibility, so it could be done in a 4.x release, but also it does significantly change behavior so it could be seen as a breaking change.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
This is a mostly working attempt: godotengine/godot#47502
The feature was approved in a PR review meeting in June 2021, but the PR is still pending.
If this enhancement will not be used often, can it be worked around with a few lines of script?
This will be used extremely often. Every Godot dev ever will use this feature.
Is there a reason why this should be core and not an add-on in the asset library?
Printing floats is a core feature.
The text was updated successfully, but these errors were encountered: