Is it possible to do something like this?
type X = object
x: uint
proc default*(T: typedesc[X]): X = X(x: 2)
when isMainModule:
var x: X
x.x += 1
echo(x.x) # prints 3 rather than 1
No, but this is a planned feature:
type X = object
x: uint = 2