Add union types to Typed GDScript
*Bugsquad edit: This proposal is a superset of #162.* EDIT: Tried to format it according to the 'template'. **Describe the project you are working on:** Was working on a game using Godot. **Describe the problem or limitation you are having in your project:** (Original text) The main reason I want it is due to Array and Dictionary type not being able to receive null values and I want to be able to use null values as the "default" value for functions. This is a very common pattern in my pre-existing code and without this ability I'm not sure what to use as "default" values. Empty arrays and dictionaries? That could cause needless memory allocations I think. Also, there could be a difference in meaning between passing an empty array and passing null to a function, for example. Also it is simpler to just use null and compare/check for null. Dictionary is used as an 'anonymous object' very often, so it makes a lot of sense to allow null. Since the type does not allow it, union types could help. This is the biggest issue that makes me not able to use Typed GDScript more in my code. **Describe the feature / enhancement and how it helps to overcome the problem or limitation:** Union types would be written as `Type1 | Type2` in place of the type. **Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:** Examples: ```gdscript # heal the target (which has its data in a Dictionary) if specified, otherwise if no target specified, heal self func h
Posted by chanon on Aug 8, 2018, 8:46 AM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Add union types to Typed GDScript
*Bugsquad edit: This proposal is a superset of #162.* EDIT: Tried to format it according to the 'template'. **Describe the project you are working on:** Was working on a game using Godot. **Describe the problem or limitation you are having in your project:** (Original text) The main reason I want it is due to Array and Dictionary type not being able to receive null values and I want to be able to use null values as the "default" value for functions. This is a very common pattern in my pre-existing code and without this ability I'm not sure what to use as "default" values. Empty arrays and dictionaries? That could cause needless memory allocations I think. Also, there could be a difference in meaning between passing an empty array and passing null to a function, for example. Also it is simpler to just use null and compare/check for null. Dictionary is used as an 'anonymous object' very often, so it makes a lot of sense to allow null. Since the type does not allow it, union types could help. This is the biggest issue that makes me not able to use Typed GDScript more in my code. **Describe the feature / enhancement and how it helps to overcome the problem or limitation:** Union types would be written as `Type1 | Type2` in place of the type. **Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:** Examples: ```gdscript # heal the target (which has its data in a Dictionary) if specified, otherwise if no target specified, heal self func h
Comments (0)
No comments yet. Start the discussion.