I am converting some Ruby code to Nim and got proc initialize(s: Step; prev, nxt, id: int) = s.prev = prev s.next = next s.id = id s.radius = 0 # default for incident net s.outer = false Run
The first 3 assignments in the proc are a pattern that occur often in my code, and so since many years I ask myself if it may be possible to have instead something like proc initialize(s: Step; prev, nxt, id: int) = s.doTheMagic(prev, next, id) s.radius = 0 # default for incident net s.outer = false Run or maybe even better but more fragile proc initialize(s: Step; prev, nxt, id: int) {.magicallyInitializeClassFieldsWithMatchingNames.} = # s.doTheMagic(prev, next, id) s.radius = 0 # default for incident net s.outer = false Run