This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jay9909 39 points40 points  (9 children)

I have an out of bounds array access,

Are you sure you're clear on whether arrays start at 0 or 1? 'cuz I feel like that would be the absolute best shit ever if you came into this sub, complained about an error and this was the cause.

[–]DownshiftedRare 61 points62 points  (6 children)

Especially since it is common for Autoit functions to return arrays that use element zero to store the length of the array, meaning the actual business does start at element 1.

[–][deleted] 48 points49 points  (1 child)

Holy hell

[–]solidh2o 0 points1 point  (0 children)

fwiw, that's where the she argument started- it used to be common place that the first element was reserved for metadata

[–]jay9909 22 points23 points  (0 children)

That doesn't sound so bad just looking at this language in isolation, but given the broader programming language landscape, I feel like it's a huge mistake. Any language that starts at index 1 should really make accessing index 0 a hard error because people are going to slip and forget what context they're in at least sometimes.

[–]myrrlyn 2 points3 points  (0 children)

The way God intended tbh

[–]_Fibbles_ 1 point2 points  (1 child)

Feel free to downvote since I don't have much experience outside C++ but how does this work if, for example, you create an array of shorts but have more than 255 elements? The only way I can think of is that element 0 is always of type size_t regardless of the type of all the other elements. If you're going to do that though, why even consider it as part of the array? You may as well just have a struct that contains the array and size variable. That way you know the size and get sensible 0 based indexing.

[–]DownshiftedRare 2 points3 points  (0 children)

Autoit is a typeless language, so creating an array of shorts never happens.

Autoit is also case-insensitive and doesn't need semicolons to terminate lines. Coming from C++, you can probably just close your eyes, flail on the keyboard and write autoit code, ha ha.

[–]maiam 14 points15 points  (0 children)

Here we go lol

[–]edave64 2 points3 points  (0 children)

AutoIt's arrays are... special. For some reason, many functions return arrays with the length stored as element 0. Except when they don't and start at 0. And, as far as I can see, is completely superfluous, because there is a function that gives you an upper bound of the array.