lep/jassdoc

Advice against "constant handle"?

Opened this issue · 0 comments

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?