import tables
var T_base: array[0..1, Table[string, char]]
T_base[0] = initTable[string, char]() # Init
T_base[0]["x"] = 'a'
echo T_base[0]["x"]
Running this code w/o the initialization in line 5 will result in a Traceback ("Attempt to read from nil?"). Is that really necessary? Why not add a check for nil (possibly - and most desirably initializing the Table dynamically)? That this is possible is shown in the CritBits module, using which, the following code runs w/o any problem:
import critbits
var
C_base: array[0..1, CritBitTree[char]]
C_base[0]["x"] = 'a'
echo C_base[0]["x"]
Also, coming back to the Tables code, please mind the double specification of T_base's generic types in initTable() (shouldn't that be known already?).
That said, I know that @Araq is not absolutely against the idea of enhancing seq[T] to auto-initialize in some cases, to avoid the runtime crashes that result from attempting to read from nil. I know this because I recently asked about that exact issue.
So, perhaps you could create a PR on Github, suggesting that a similar allowance be made for Table[A, B]. You could suggest that if some code attempts to index into an uninitialized Table instance, the table will first be default-initialized to the initial-length of 64.
I would suggest you open a PR.
Ha, you're right, @OderWat. Last week I knew that "PR" == "Pull Request", but for some reason yesterday, my brain decided that "PR" == "Problem Report". ;)
(Ah well, time for me to create some pull requests.)