Pass-by-reference?

Started by deltamatrix, Sun 16/10/2011 11:42:20

Previous topic - Next topic

deltamatrix

Hi,

Sorry if this has already been asked but does AGS support pass-by-reference for primitives? I have some code that would look far cleaner and more concise if any form of pass-by-reference was supported.

Thanks

Delta
BAD WOLF - TORCHWOOD - MR SAXON - THE BEES ARE DISAPPEARING - PANDORICA - RIVER SONG

Calin Leafshade

nope, fraid not.

you can only pass built in objects (Character, GUI, etc)  by reference.

deltamatrix

dang. I hope the open-source devs do consider it. This means I gotta bulk up the src with repeated code.
BAD WOLF - TORCHWOOD - MR SAXON - THE BEES ARE DISAPPEARING - PANDORICA - RIVER SONG

Denzil Quixode

Closest thing I could think of: you could try "boxing" values by placing them in a 1-length dynamic array and passing that:
Code: ags
function change(int thing[])
{
  thing[0] = 20;
}

function test()
{
  int thing[] = new int[1];
  thing[0] = 10;
  change(thing);
  Display("%d", thing[0]);
}

SMF spam blocked by CleanTalk