Is it possible to have an array as a parameter to an action?

Slapshot136

Divide et impera
I seem to have the array option for local variables, but not for parameters (using a unit variable) - is there any reason for this? or a workaround? or am I just doing it wrong?
 

jonas

Well-Known Member
It should be possible to pass a reference to an array that lives in the global memory or deeper in the stack.
 

Slapshot136

Divide et impera
If the array was in global memory, there wouldn't be much need to pass it as a parameter - not sure I understand what you mean by "deeper in the stack", but lets say I have a function foo which currently takes two units as a parameter - I want to change it to take a unit[2] instead (to make it prettier) - is there any way to do so? (OK, it's a bit uglier in my case than a single unit[2], but you get the idea)
 

jonas

Well-Known Member
The galaxy version should still work, that post is unrelated. By the way, you can always use the old 2d array tricks. You could look at the generated code of jasshelper for the dynamic arrays if you're not sure about the details, but it's really just using a global 2d array... I'm pretty sure that this can also be done in GUI.
 

Slapshot136

Divide et impera
using a global array seems.. inefficient.. but I guess it would work as a work-around (albeit more inefficient than a proper parameter)
 

jonas

Well-Known Member
EDIT: The performance should be about on the same level. In one case you might have the compiler initializing the array when allocate it on the stack, in the other case you have some more loads abd arithmetic (loading the base address of the 2d array, adding the index from the variable). Depending on whether you want to keep references around or just pass them as you described, you might have to add some free list to manage the references which are being in use - slightly more code and performance overhead. Either way, don't worry about it too much and don't expect a slowdown greater than 2x. Struct usage in JASS was worse (+OP Limit and slow speed of JASS), and no one ever had problems with it.

It's just less beautiful and practical (in that it limits your recursion depth and requires you to have a huge portion of the memory in stand-by mode).
 
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    Didn't the backwards compatability have issues too?
  • Accname Accname:
    I never had any hopes for that. Blizzard is not the same company it was 10 years ago.
  • The Helper The Helper:
    It happens in corporations. They just absorb the companies they buy and it is not about the love of making awesome games it is how much money can we make with the least amount of cost.
  • The Helper The Helper:
    Blizzard is watered down now hopefully they can pull it together
  • The Helper The Helper:
    they got a server engineer job opening :)
  • Ghan Ghan:
    I really do not want to move to California otherwise I might consider it.
  • The Helper The Helper:
    yeah California is not anywhere you really want to live
  • The Helper The Helper:
    That is why I did not take the job Blizzard offered me back in the day, there is no way I could have moved my family there on what they were offering, not even close and that was like 20 years ago
  • The Helper The Helper:
    yeah they wanted me on the tech support team when they did not get me they got one of the next MVPs in Dinobot
  • The Helper The Helper:
    Dinobot was one of the youngest of the MVPs tkron probably could have worked for Blizzard but he had a good job in Chicago doing business programming already
  • The Helper The Helper:
    Dinobot probably still works for Blizzard would love to reconnect with that guy
  • The Helper The Helper:
    I wonder what ever happened to Wargasm?
  • The Helper The Helper:
    This new version of Xenforo really is awesome
  • Ghan Ghan:
    Wargasm is still around. He works for the domain registrar where thehelper.net is kept.

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top