• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Chained Accessors?! Are they planned or must we forget it?!

xDGameStudios

GameMaker Staff
GameMaker Dev.
Hi every one, I'm here to make a request... tough we have marketplace extensions to do this.. there is still some performance that is lost using other methods. I wanted to request for adding this feature to GML in GMS2. it would not be that difficult (I think)!
For lists, maps, grids we have functions...

Code:
ds_list_find_value(ds_list_find_value(ds_list_find_value(list, 0), 2 ), 3)
is possible!! (not fast to write... but possible) :p

what about arrays? with arrays we need this:

Code:
a1 = array[0];
a2 = a1[2];
value = a2[3];
if we need to mix those together, it would be a nightmare of code lines:
this would be way better:

Code:
 v = a1[0][2][3]
or (if needed):

Code:
 v = ((a1[0])[2])[3]
NOTE: Sometimes we want something fast and easy to write... not really concern with readability... this would be a feature I think (extension) developers would like a lot.
 

rwkay

GameMaker Staff
GameMaker Dev.
We are working on allowing this sort of array (and accessor) dereferencing, unfortunately the worked required is more than you would anticipate due to some low level architectural changes.

We are working on getting GMS2 out of the door first and then will return to those changes required to allow this to happen.

This is something that we want to happen and it is on our internal roadmap, but I cannot promise a date when it is going to happen at this stage

Russell
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
We are working on allowing this sort of array (and accessor) dereferencing, unfortunately the worked required is more than you would anticipate due to some low level architectural changes.

We are working on getting GMS2 out of the door first and then will return to those changes required to allow this to happen.

This is something that we want to happen and it is on our internal roadmap, but I cannot promise a date when it is going to happen at this stage

Russell
Date is not of the matter.. the confirmation itself means a lot! thank you
 

rwkay

GameMaker Staff
GameMaker Dev.
@YellowAfterlife - this is part of the low level architectural changes that need to happen and will be addressed to do this change, initially I thought this would reasonably simple to implement and then realised that there were deeper structural changes that needed to happen to make it all work properly as expected.

NOTE: This structural changes should benefit across the board and will facilitate other language features coming in, it will also simplify some issues around 2D arrays as they are currently unsatisfactory in my opinion.
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
@YellowAfterlife - this is part of the low level architectural changes that need to happen and will be addressed to do this change, initially I thought this would reasonably simple to implement and then realised that there were deeper structural changes that needed to happen to make it all work properly as expected.

NOTE: This structural changes should benefit across the board and will facilitate other language features coming in, it will also simplify some issues around 2D arrays as they are currently unsatisfactory in my opinion.
I had one extra question that I wanted to know the answer to!!
Would implementing chain accessors... also allow the use of:

Code:
var script_pointer = my_script;

script_pointer()
or are they too completely different features?
 

gnysek

Member
NOTE: This structural changes should benefit across the board and will facilitate other language features coming in, it will also simplify some issues around 2D arrays as they are currently unsatisfactory in my opinion.
I just wanted to report that there's no way to differentiate 2D and 1D array, but then I'm not creating a new request for it, as you probably going to change it anyway with mentioned changes.
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
I just wanted to report that there's no way to differentiate 2D and 1D array, but then I'm not creating a new request for it, as you probably going to change it anyway with mentioned changes.
I read (Mike or Russel, not sure who) that 2D arrays as they are will cesse to exist...
it will always be and array of arrays:

So:

arr[4][2]

Instead of the current:

arr[4, 2];

NOTE: as far as compatibility goes.. maybe they'll will keep the arr[x, y] but in the backend it will be switched to arr[x][y]
 
Last edited:

zbox

Member
GMC Elder
I do have a free asset to access embedded structures that I genuinely use all the time, it's kind of a lifesaver if you heavily rely on complex data structures.
 

GMWolf

aka fel666
@YellowAfterlife - this is part of the low level architectural changes that need to happen and will be addressed to do this change, initially I thought this would reasonably simple to implement and then realised that there were deeper structural changes that needed to happen to make it all work properly as expected.

NOTE: This structural changes should benefit across the board and will facilitate other language features coming in, it will also simplify some issues around 2D arrays as they are currently unsatisfactory in my opinion.
Will this change the way array currently work?
Because I swear the fact arrays are created and copied when writing to then causes a bug or two every time I use them. Either by forgetting to use accessors, or because I forget to check for undefined and GM creates a new array when I would have preferred an error, making the whole thing very hard to debug.
 

gnysek

Member
I even saw somewhere, that they want to add real types in GM, so you instead of as now, assigning real number to variable, you would have assigned resource type. For example now (using default names from GMS) object_0 == sprite_0 == script_0 == room_0, as all those values are 1. In future, comparing like this will return error "cannot compare int with resource_(room, etc.)". Also, when checking for is_room(sprite_0) it will return error, while for now it would return true.
 
Top