> Well you can call printSqured(b) and have its T inferred and that makes all 
> the difference.

True. Two different ways around this:

  * calling it like this `printSquared()(b)` to indicate the inferred first 
parameter list (sucky IMHO) or
  * defining it in upper-case


    
    
    proc PrintSquared(T)(o: A(T)) =
      echo o.x * o.x
    
    
    Run

in analogy to the "upper-case names for types (i.e. classes of concrete 
instances ), lower-case names for values (i.e. concrete instances)" rule. If we 
don't want to rely on just identifier case, a new keyword would help:
    
    
    procclass PrintSquared(T)(o: A(T)) =
      echo o.x * o.x
    
    
    Run

More typing, but only in the definition.

None of these are perfect, but "`()` is for parameter tuples, `[]` is for 
dereferencing by index" is just too nice to lose it to generics.

As for generic types, independently of generic procs, parentheses instead of 
brackets could be used right away.

Reply via email to