lol. fair. me too.

i agree the Hand(string) constructor for distinct types is an attractive 
nuisance. we can get rid of that. but you'll have to have the self-control not 
to use `cast`.

what you can do is, put your Hand type, and its constructor in a separate 
module, and only export the type and its constructor.
    
    
    #hand.nim
    type Hand* = object
      val: string
    proc init*(t:typedesc[Hand],s:string):Hand = #...validate...#
    
    
    Run

then when you
    
    
    #main.nim
    import hand
    let x = Hand(val: "INVALID") #static error, the field 'val' is not 
accessible
    let y = Hand.init("INVALID") #runtime error
    
    
    Run

Reply via email to