oh i know, nimsuggest crashes and it does take ages to populate that 64MB
array, and yes while testing there were several times i got a SIGKILL. i'm
trusting that it's a crucial optimization for your use case. bear in mind `let
defaultB:B = <whatever>` will calculate the result at runtime, the tradeoff
being a 64MB smaller binary.
if you want
a)an init function for `B` b)defaultB defined as `let` c)a `hi` function
with no side effects d)nimsuggest not to crash
here's how:
func initB(res:var B) =
for i in 0'i32..63:
for j in 0'i32..63:
for k in 0'i32..63:
for l in 0'i32..63:
res[i][j][k][l] = i+j+k+l
func initB():B =initB(result)
let defaultB = initB()
func hi(d:B,i:int32):int32 = d[i][i][i][i]*i
when isMainModule:
import random
randomize()
echo defaultB.hi(rand(63).int32)
Run