HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Drawing the line

07-13-2008, 05:17 PM#1
Vexorian
So, as people begin to use vJass, certain abuses are getting evident. Like people complaining of this not working:

Collapse JASS:
struct T
    timer t=NewTimer()
endstruct

The fact that it usually compiles when using natives there is causing people to think it is legit to use functions in default values. So, I think that it is a good idea to make it show a syntax error if a function is used.

Now, what else shouldn't be allowed? Let's begin saying that constants obviously should remain allowed.

global variables? I've seen somebody and myself use global variables there, for example if you have previously calculated the center of the map the default point could be that.

It might be too much freedom, then we could force it that the struct's static members are the only sort of global allowed there. But if the member is not public it is the same issue, really. So force a private static member? I think globals in general are ok.

It is very useful to allow static members there. Could be a way of tweaking the defaults or to pass info to create() when some limiting factors are involved, like when using an interface.create() .

How about operations?I think it is ok as long as they don't call a function?
07-13-2008, 06:08 PM#2
Troll-Brain
In a perfect world people check the war3map.j to know what exactly the vJass compile.
But maybe some people don't know how to look the generated script.

I'm agree with your ideas.
07-13-2008, 10:53 PM#3
d07.RiV
It it true that the only reason why functions can't be used is because the allocate function is declared at the top of the script?
Then, why is it declared there? It seems logical that the struct is available after it has been declared, like in normal languages. If that's not happening, then all right, I don't really see the need of initializing members with functions (it can always be done in the create function). But why not allow globals? What's wrong with people modifying initial values outside the struct?
07-13-2008, 11:11 PM#4
Vexorian
Quote:
Then, why is it declared there?
I am not a fan of making allocate() require TriggerEvaluate to work well.

Quote:
It it true that the only reason why functions can't be used is because the allocate function is declared at the top of the script?
There's also a reason they shouldn't be allowed to be used, doing so is an abomination...