> Any idea what I am doing wrong and how to fix it ?

Instead of storing the proc as a field, why not use the type for static 
dispatch ?
    
    
    proc sendProc(s: AsyncNNTP, ...) = discard
    proc sendProc(s: NNTP, ...) = discard
    
    proc new(T: typedesc[NNTP | AsyncNNTP], host: string, port: Port, tlsPort = 
port, user, pass: string, tls: bool): T =
      result = T(host: host, port: port, tlsPort: tlsPort, user: user, pass: 
pass)
      when T is NNTP:
        result.sock = newSocket()
      else:
        result.sock = newAsyncSocket() # no need to store the proc
    
    
    Run

Reply via email to