Is there a way to define a proc inside a file that is called from an imported 
module. My idea is that I will have a library for doing common operations on an 
object that has a generic type associated with it. Then a user could define a 
desired behavior for some custom type that is triggered during one of these 
common operations.

In the module I have the default behavior which is to do nothing when there is 
no associated generic type.
    
    
    # module.nim
    
    type
      Object[T] = object
        data: T # optional type parameter
    
    proc second(obj: Object[void]) =
      discard
    
    proc first[T](obj: Object[T]) =
      second(obj)
    
    
    Run

If this module is imported could I define another `second()` proc for some 
other type such as a string as a simple example?
    
    
    import mod
    
    proc second(o: Object[string]) =
      echo o.data
    
    var
      obj = Object[string](data: "Data")
    first(obj)
    
    
    Run

I have a related but less pressing question. What does the compiler end up 
doing with a proc like:
    
    
    proc second(obj: Object[void]) =
      discard
    
    
    Run

Would this be expected to have any additional overhead at runtime?

Reply via email to