@gemath That's also something I had in mind ;).

The problem with autogenerating getters/setters for `var x*` expressions is 
that closures don't allow the regular `field` / `field=` syntax as far as I can 
see. For instance:
    
    
    type
      Obj = ref object
        step: proc(): int
        `step=`: proc(x: int)
    
    let o = Obj(step: proc(): int = 0, `step=`: proc(x: int) = echo x)
    echo o.step()
    o.`step=`(1)  # I guess only this syntax is possible
    
    
    Run

So you cannot just use something nice like `o.step = 1`. Thus, it's probably 
better to use different names for the getter and setter. The auto-generated 
getter/setter could follow a fixed convention like `step`/`setStep` or 
`getStep`/`setStep`. In the end I preferred to give the user control over how 
they call them with the current getter/setter shortcuts.

I also tried to use the `Counter of SomeBaseClass` syntax, but for the overload 
analysis it is important to pass in the base class as a `typed` macro argument. 
`Counter of SomeBaseClass` would require an `untyped` argument, and I don't 
think it would be possible to access the type impl in this case. That's why I 
went for the slightly less appealing `classOf(Sub, Base)` syntax, and that's 
also why generic subclasses will probably require a minor repetition 
`classOfGeneric(Sub[X, Y], Base, Base[X])` \-- the first appearance of `Base` 
is a typed arg, the one with the generics is untyped.

Reply via email to