ZScript 2D array assignment and access orders swapped?

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: ZScript 2D array assignment and access orders swapped?

Re: ZScript 2D array assignment and access orders swapped?

by phantombeta » Tue Jan 08, 2019 9:42 am

Graf Zahl wrote:Heh. I was thinking about convoluted approaches on a later stage, I actually never thought about brute-force altering the parser's output on the AST level...
Sometimes a naive approach can be the best one. :P
It should still use std::move to assign the swapped array (or swap in-place.)

This should also be versioned 3.7.2, I think, so it can be in the next point release.
Done and done.

Re: ZScript 2D array assignment and access orders swapped?

by Graf Zahl » Tue Jan 08, 2019 8:56 am

Heh. I was thinking about convoluted approaches on a later stage, I actually never thought about brute-force altering the parser's output on the AST level...
It should still use std::move to assign the swapped array (or swap in-place.)

This should also be versioned 3.7.2, I think, so it can be in the next point release.

Re: ZScript 2D array assignment and access orders swapped?

by phantombeta » Tue Jan 08, 2019 8:49 am

PR link. Versioned, obviously. Fixes array definitions for version 3.8.0 and above
Was actually pretty easy to fix.

Re: ZScript 2D array assignment and access orders swapped?

by Major Cooke » Wed May 24, 2017 2:04 pm

We've already broken D4D over multiple versions. I don't mind it.

At any rate, I don't think there are any multi-dimensional arrays being used zscript wise with D4D so far...

Re: ZScript 2D array assignment and access orders swapped?

by Graf Zahl » Wed May 24, 2017 1:57 pm

If this gets addressed it needs to be versioned. But of course with D4D that can be a problem, if it sees continued development...

Re: ZScript 2D array assignment and access orders swapped?

by Major Cooke » Wed May 24, 2017 1:03 pm

If this is true, I better go back through D4D and untangle any multi-dimensional arrays immediately or there will be hell to pay when fixed.

ZScript 2D array assignment and access orders swapped?

by Nash » Thu May 18, 2017 2:52 am

Mikk- wrote:Okay stupid question but can 2D arrays not have a larger second dimension than the first dimension?
Say for example I have an array defined as test[8][11] - if I then assign index [1][9] I get an out of bounds error..? but if I assign index[1][7] I do not get an error, which is rather strange...

Code: Select all

class c_arraytest : actor
    {
    
    int c_testarray[8][11];
    
    override void postbeginplay()
        {
        super.postbeginplay();
        
        c_testarray[1][9] = 1;
        }
    }
Gutawer wrote:It's kinda weird, but the assignment order for the dimensions and the access order are actually swapped around, you probably want int c_testarray[11][8] instead. That little problem had me annoyed for at least half and hour when I ran into it, lol.

Top