HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Global declaration freedom... with locals?

08-22-2009, 02:29 AM#1
Vosty
If you can declare globals anywhere in your script, can you declare locals anywhere in a function? (Like after functions calls and waits and stuff.)
If not, it should be implemented. I couldn't think of anyway that would be difficult, seeing as it would just place them at the top of the function.

Just my simple thinking. If you can already do it, I guess I got to read a few more vJass scripts before I get good. I just learned about a week ago.
08-22-2009, 03:00 AM#2
Vexorian
It's not difficult to implement, but I don't see much sense in doing so. It doesn't really serve any good purpose, once you reach to that point, you might be better making a second function.
08-22-2009, 03:16 AM#3
TotallyAwesome
Actually, I don't think it'd be hard to be done via jasshelper, it's just that it wouldn't serve any purpose, as Vex said, and would not only complicate things, but make stuff much messier too.
08-22-2009, 03:51 PM#4
Vosty
Well....
I just kinda thought it up while reading a c++ tut (Since in the old C, you had to declare variables at the top.
For really long scripts, you gotta pan all over just to find where the local is used.
Then you could insert it where you need it, but that might get a little messy if totally abused by inserting one after every call.
It would be okay, when showing a function as if it were in steps, for learning purposes, if you could create the locals for each step, rather than mashing 8+ locals in the top.
Just my opinion. I'm not gonna pester you all day with Pros and Cons.
08-22-2009, 03:56 PM#5
Vexorian
In C++ it makes sense because of constructors and how the stack works.

In Jass it is all pointers, and well...
08-23-2009, 01:29 AM#6
Vosty
Admit it compared to c++, jass is kinda crappy (except for memory usage. I like how integer is integer of ANY size, and that is final.)

Yeah, it's ok, just leave it, I read more tuts and it makes sense now anyway.
I like how yur sig say's no .rar files.
I am trying to get Pjass in a .zip or .7zip file. Do happen to got something you can give me?
Pitzermike ain't listening to me currently.
EDIT: NM!