When accessing an element in an array the square brackets are used like so:
{'X is an int and Numbers is an int array'}
X := Numbers[8];
However, While reading others’ code I sometimes find the following syntax:
{'PBox , SBox1 , SBox2 are arrays of int , And X,Y are ints'}
Result := Result or PBox(.SBox1[X] or SBox2[Y].);
- What does it mean to have parentheses after the array’s name, as in
PBox(someNumber)? Is this another way to access an array element? - What does the “.” before SBox1 and after SBox2 mean? Both SBox1 and SBox2 are arrays. The code compiles without error but I don’t know what those dots are for.
Yes, now I see what you do.
In fact,
(.and.)are merely alternative ways (but very uncommon!) of writing[and]in Delphi.If
PBoxis an array, thenPBox[a](or, equivalently,PBox(.a.)) would requireato be an integer, right? And ifSBox1[x]andSBox2[Y]are integers, so is the bitwiseorof them. (Bitwiseoris an operation that takes two integers and returns a new integer.) Hence,PBox(.SBox1[X] or SBox2[Y].)is the(SBox1[X] or SBox2[Y])th element in the arrayPBox, that is, an integer. So it makes sense to compute the bitwiseorbetweenResultand this integer, which is what is done: