Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In 2023, Godot still does not have type unions !!! #8135

Closed
Johnrobmiller opened this issue Oct 15, 2023 · 1 comment
Closed

In 2023, Godot still does not have type unions !!! #8135

Johnrobmiller opened this issue Oct 15, 2023 · 1 comment

Comments

@Johnrobmiller
Copy link

Describe the project you are working on

This is such a basic feature, I'm shocked GDScript doesn't have this.

If you don't know what I'm talking about:

var float_or_string: float | string = "string" # this is a union
float_or_string = 3.14 # does not throw error

GDScript looks very primative without basic type features. I don't think it's possible to achieve type safety without a basic set of tools which include type unions.

This is honestly very bad, and I think that implementing basic features like this should be high priority.

Describe the problem or limitation you are having in your project

Cannot achieve type safety using Godot

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Godot needs at least the minimum set of features needed to write typesafe code.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Typescript is a great example of how this should work: https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html

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

There is no workaround for not having basic features like this.

Is there a reason why this should be core and not an add-on in the asset library?

People are not going to write typesafe code without a basic set of features that enable them to do so. People spoiled by typescript and strongly typed python will be looking at GDscrpit and immediatly see how unsafe the language is due to it's lack of type features. They might still use it anyways because Unity's leadship is so terrible and the rest of Godot is fine.

@Johnrobmiller Johnrobmiller changed the title Where are type unions?? In 2023, Godot still does not have type unions !!! Oct 15, 2023
@Calinou
Copy link
Member

Calinou commented Oct 15, 2023

Thanks for the proposal! Consolidating in #737 and #4872.

PS: I have to remind you that we have a Code of Conduct. Please stay constructive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants