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

Allow static typing of any object #1882

Closed
Shadowblitz16 opened this issue Nov 23, 2020 · 8 comments
Closed

Allow static typing of any object #1882

Shadowblitz16 opened this issue Nov 23, 2020 · 8 comments

Comments

@Shadowblitz16
Copy link

Shadowblitz16 commented Nov 23, 2020

Describe the project you are working on:
NetworkTest

Describe the problem or limitation you are having in your project:
not to the project but the static typing as a whole

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
allow static typing for anything that derives from object :as well as assignment support:=`

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

var _scene    : PackedScene
var _node     : NodeType
var _resource : ResourceType
var _custom   : AnyCustomType
var _enum     : MyEnum
var _const    : MyConstEnum
var _refrence : Refrence

If this enhancement will not be used often, can it be worked around with a few lines of script?:
It would be used for #173
And no it can't be worked around.

Is there a reason why this should be core and not an add-on in the asset library?:
Static typing in my opinion is far superior. not only does it allow to type information on autocomplete it also makes sure nothing is going to break or do anything its not suppose to do.
It also can be used for type checking so you don't get have cyclical dependencies and runtime include errors

@Shadowblitz16
Copy link
Author

The 1878 reference was a typo its not related

@Calinou
Copy link
Member

Calinou commented Nov 23, 2020

Duplicate of #192.

@Shadowblitz16
Copy link
Author

@Calinou this one covers more cases

@Calinou
Copy link
Member

Calinou commented Nov 23, 2020

@Shadowblitz16 Yes, but proposals should remain focused on a specific item. Proposals that are too widely scoped will be closed in favor of more specific ones. Otherwise, we'd never be able to close any proposal since each pull request would only implement a small part of them.

@Shadowblitz16
Copy link
Author

ok I'll make a separate one for object then

@Shadowblitz16
Copy link
Author

Shadowblitz16 commented Nov 23, 2020

@Calinou wait this is specificity for object.
Object is the base type so adding static typing for it would cover more most cases.

EDIT I modified the question to be a bit more specific

@Calinou
Copy link
Member

Calinou commented Nov 23, 2020

@Shadowblitz16 You can already use any class inheriting from Object as static type hint. However, a named enum is not an object type. This is why you can't use it as a type hint in GDScript. (As a workaround, you can still use an int as a type hint, which is better than nothing.)

@Shadowblitz16
Copy link
Author

you right i think I was thinking of exports.

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