I've inherited this bit of code and can't figure out what it does. The definition looks simple enough:
result : BOOLEAN ;
LOOKUP_TABLE : array
( BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN,
BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN ) of
BOOLEAN := (others => (others => (others => (others => (others => (others => (others => (others =>
(others => (others => (others => (others => (others => (others => (others => (others =>
TRUE ))))))))))))))));
In the body, it is used as follows:
result := LOOKUP_TABLE(TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE,
FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE );
when dumping the lookup_table in GDB it creates a line that is over 500,000 characters long, the first little bit looks like this:
$1 = ((((((((((((((((true, true), (true, true)), ((true, true), (true, true))), (((true, true), (true, ...
Originally my question was going to be: How can a 16-boolean array be reduced to a single bool "result"?, but after looking at it in GDB, I have to ask "What is this thing???"
PS: After the call in the body, the LOOKUP_TABLE is still 500,000 characters, where every boolean field is TRUE...
In Ada, an array isn't neccessarily indexed by an int starting from 0. In this case, you have multi dimensional array with booleans as indexes.
When initializing an array, you have to specify the whole range of the array.
A one dimensional array would look like this:
Lookup_Table : array(Boolean) of Boolean := (False..True => True);
When dealing with larger arrays, it's inconvenient to specify all alternatives, hence the keyword others
.
It means all alternatives not yet specified, so this is the same as above:
Lookup_Table : array(Boolean) of Boolean := (others => True);
This array now looks like this (1 being the dimension, and C being the content):
1 | C
-----|-----
False|True
True |True
In a two-dimensional array, this would be:
Lookup_Table : array(Boolean, Boolean) of Boolean := (others => (others => True));
1 | 2 | C
-----|-----|-----
False|False|True
False|True |True
True |False|True
True |True |True
In your case it's 16 dimensions.
You can read more about Ada array here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With