It’s possible to create an immutable object using an `init` constructor as you 
said in your next post. For instance:
    
    
    type
      Foo = object
        f: int
    
    proc initFoo(x: int): Foo =
      result.f = x
    
    let foo = initFoo(7)
    echo foo
    
    
    type
      FooRef = ref Foo
    
    proc initFooRef(x: int): FooRef =
      new(result)
      result.f = x
    
    let fooRef = initFooRef(8)
    echo fooRef[]
    
    
    Run

You could even define a constant for the Foo type by replacing `let` by `const`.

Reply via email to