Nim has no mechanism to safely reference a value type, as such you need to 
raise the `original` to a `ref seq[int]` like so
    
    
    var original = new seq[int]
    original[] = @[1, 2, 3, 4, 5]
    
    type
      Thing = object
        # I would like `list` to be set to a *reference *of `original`
        list: ref seq[int]
    
    proc initThing(list: ref seq[int]): Thing =
      result.list = list
    
    var thing = initThing(original)
    
    proc show(label: string) =
      echo "\n", label
      echo "Original:  ", original.repr
      echo "Reference: ", thing.list.repr
    
    show "Initial:"
    original[0] = 666
    show "Updated:"
    
    if thing.list[0] != 666:
      echo "\nNot a reference!"
    
    
    
    Run

Reply via email to