Is there any way to have a default type for an initializer for generics?

I would like to allow users to call it without specifying type information to 
get a default type. It seems obvious this is not directly supported, but is 
there a way to achieve this behavior?
    
    
    type Foo[T] = object
      x: T
    
    proc initFoo[T](): Foo[T] =
      result
      # works
    
    #[
    proc initFoo(): Foo[string] =
      result
      # error "would lead to ambiguous calls"
    ]#
    
    let a = initFoo[int]()  # works
    
    #[
    let b = initFoo()  # error: cannot instantiate T
    ]#
    
    
    
    
    Run

Reply via email to