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

Advice against "constant handle"? #85

Open
Luashine opened this issue Nov 10, 2022 · 0 comments
Open

Advice against "constant handle"? #85

Luashine opened this issue Nov 10, 2022 · 0 comments

Comments

@Luashine
Copy link
Collaborator

As a part of #73 I was going to add this note, but decided to look further into "why":

+@note You should not initialize game sounds as constants in Jass (why?)

In a reply there moyack says that the problem he had was due to a constant sound handle. He had an issue after loading a saved game.

Searching further, all I really found were posts on hive like this:

You shouldn't use handle variables as constant globals, make them nonconstant.

And then the only interesting discussion here, where nobody understands the logic of constant vs non-constant functions, and for handles only the issue with "wc3mapoptimizer" is pointed out (wrongly constant-folding handle variables). Though that's different from whatever bug moyack had after game load.


Basically, does anybody know what constants are good for (except basic types like int)? Should we add a general warning to handle type? (and then each descendant type too?) to never save handles as a constant?

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

No branches or pull requests

1 participant