for property access you can use a distinct type and for assignment an operator
like :=
type
Obj = ref object
fStep: int
ObjStepProperty = distinct Obj
template step(self: Obj): ObjStepProperty = self.ObjStepProperty
proc `:=` (self: ObjStepProperty, val: int) {.inline.} =
self.Obj.fStep = val
converter toInt (self: ObjStepProperty): int {.inline.} = self.Obj.fStep
when isMainModule:
var o = Obj()
echo o.step
o.step := 2
echo o.step
Run
- closure_methods: OOP purely based on closures bluenote
- Re: closure_methods: OOP purely based on closures Araq
- Re: closure_methods: OOP purely based on closures bluenote
- Re: closure_methods: OOP purely based on closures gemath
- Re: closure_methods: OOP purely based on closure... bluenote
- Re: closure_methods: OOP purely based on cl... adrianv
