-
Notifications
You must be signed in to change notification settings - Fork 23
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
Static typing #23
Comments
I'm well aware of how to do this :) The issues I have encountered are that I hit cyclic dependencies very quickly. |
But cyclic dependencies are not a problem with global classes? |
Yes, i am pretty sure everything is fine with the usage of I have this code in a project that i have been working on for months without any problems:
I am pretty sure i have a shitton of other cyclic references everywhere. |
It very well may be an issue with |
As i said, i have used I have made a pr to your I have disabled typing warnings for now, since they create a ton of messages. I can continue changing things in this direction. though i am not sure if i should work on that branch, as it is quite a bit behind on commits, and changes such as mine are ought to cause merge conflicts. Also, maybe you can tip me what exactly to change? Where did you encounter problems before? It would be good to work on problematic parts first. |
And I have encountered it very quickly 🤷🏻
As you have already noticed, this branch is outdated. There isn't much sense in doing anything with it in it's current state.
The intention is on the contrary - to have them bumped up to errors.
My intention is to have everything fully typed.
I avoid using intellisense-style autocompletion because I have seen enough developers who are completely clueless once it breaks. And it always breaks at some point. I use token-based autocompletion instead. And even that breaks sometimes, but I don't care too much because I can handle it.
I'm afraid I don't have much in terms of tips. The current PR is already too much for me to follow or review. All of this is just a hobby project, it doesn't really have any goals. |
It is actually pretty robust.
You can always declare a new variable with the type you are using, even if you are in a completely typeless environment. In the end, it's really nice to have features of autocomplete and ctrl-clicking to hop around, even if they don't work sometimes. Just because you can't always use a car doesn't mean you have to exclusively ride a bike. Anyway, should i even commit such massive changes with typing? They are pretty all-encompasing, and i do not have the full grasp of your code. |
I am not entirely sure what you mean by this milestone, there are multiple ways to achieve it.
First is
const x := preload(...)
which i personally have had problems with. Even in smaller projects things that use preload just randomly break sometimes, not loading scenes or scripts and showing bullshit errors. Not even sure if 4.3 solves it entirely.Second option is using
class_name X
on top of scripts. I use this option extensively, basically just naming every single class and using them as types similar to int or float. It works perfectly:Class name gets registered globally, which is often very convenient, and also allows the usage of static vars and funcs.
Of course, godot still has no namespaces for this feature, which can create a problem of conflicts and pollution of global space, but i do not think your project's scale is large enough to worry about that.
I'd suggest transitioning to the second option. Having everything (almost, i don't do that for most of UI) as a globally named class makes coding experience very similar to a fully typed language, like C#.
The text was updated successfully, but these errors were encountered: