E.g. so:
    
    
    # module1.nim
    type SomeClass* = object
          m_Var1: int
          m_Str1: string
          m_For_Prop: int
    proc newSomeClass*: SomeClass =
      result.m_Var1 = 5400
      result.m_Str1 = "A String from consrtuctor"
    proc PrintMembes*(self: SomeClass) =
      echo self.m_Var1
      echo self.m_Str1
      echo self.m_For_Prop
    proc AProp*(self: SomeClass): int =
      self.m_For_prop
    proc `AProp=`*(self: var SomeClass, value: int) =
      self.m_For_Prop = value
    
    # module2.nim
    import module1
    
    var Aclass = newSomeClass()
    Aclass.PrintMembes
    Aclass.AProp = 555
    
    
    Run

  * `self` is just a parameter name, you can use `this`, `obj` or whatever you 
want instead
  * `*` is to make public: that is you can access these symbols in other modules
  * the set of procedures working on a type is not fixed, you can add such 
"methods of SomeClass" in other modules; and you can call them like 
`PrintMembes(Aclass)` too; they are just procedures


Reply via email to