I was cleaning up my chess game, which includes replacing var default values by 
consts generated at compile time.

For the code below output of echo is zero for all values, while I expected 
low(int16). What may be wrong?
    
    
    const
      MaxDepth = 15
    
    const
      InvalidScore = low(int16)
    
    type
      Guide = tuple
        v: int16
        si:int8
        di:int8
      
      HashLine = array[-MaxDepth..MaxDepth, Guide]
      
      HashResult = tuple
        age: int # set to zero for last access, increase for each played move
        score: HashLine # exact values
        floor: HashLine # lower bounds
    
    proc genHashResultAllZeroConst: HashLine =
      for i in mitems(result): i.v = InvalidScore
    
    const
      HashResultAllZero = genHashResultAllZeroConst()
    
    proc initHR(hr: var HashResult) =
      hr.age = 0
      hr.score = HashResultAllZero
      hr.floor = HashResultAllZero
      for i in -15..15:
        echo hr.score[i].v
        echo hr.floor[i].v
    
    var hr: HashResult
    initHr(hr)
    

Reply via email to