Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Bug Reports / multi-dimention array doesn't require multiple indices?

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Jun 2011 11:52
I don't know if this is a bug or if DB was designed this, but look at the code and you'll see what I mean.



KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 24th Jun 2011 17:21
It prints a 3, which is in thing(2,0).

If you don't supply it, it assumes you are referring to index 0.

However, it might be a good idea to throw an error from the compiler for a situation like this. If it's an unintentional typo it could be maddening to track down.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Jun 2011 01:52
It's sometimes a useful feature. Arrays are usually stored as one long list - the subscripts just make it easier for humans to find their way around them when coding and reading code.

My guess is that multi-dimensioned arrays carry a slight overhead since the actual position in the list needs to be calculated from the subscripts. This is usually far outweighed by the extra readability and coding simplicity it provides.

I'd expect it to be slightly more efficient to clear an array using a single subscript rather than use the subscripted version for example. Could be wrong though. Someone whose name mustn't be mentioned will know the precise answer.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Aug 2011 00:32
Quote: "Someone whose name mustn't be mentioned will know the precise answer. "

Voldemort?

It's a side-effect of DBPro's array design, and has been deemed 'good'.

Individual array subscripts are used to calculate the offset into the array only - they aren't individually tested to see if they are in range (bounds checking is carried out on the calculated offset though) and there are no checks to see if the right number of subscripts have been provided.

... and yes, it is slightly faster - For each additional subscript following the first, there's also an additional multiply & add IIRC

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Aug 2011 01:45
Quote: "Voldemort?"


Possibly. Or this perhaps?

The One Whose Name Cannot Be Spoken

Or even this:

The fount of all knowledge

Login to post a reply

Server time is: 2024-04-26 22:00:14
Your offset time is: 2024-04-26 22:00:14