@cdome Thank you.

I am writing function like map, it will take the type array, slice, seq, 
iterator, etc as parameter, because the iterator cannot be treated as typed, so 
I cannot use typed(If the paramter type is typed, the function in the code can 
compile successfully).

The code like this works:
    
    
    type outType = type((
          block:
             when compiles(seq1.len) and not (seq1 is string):
                when seq1 is array[1, Slice]: (var it{.inject.}: 
type(seq1[0].a);)
                else: (var it{.inject.}: type(seq1[0]);)
             elif seq1 is Slice: (var it{.inject.}: type(seq1.a);)
             else: (var it{.inject.}: type(seq1);)
             op))
       var result: seq[outType] = @[]
    

I have several function like this, so I hope I can use an template to wrapper 
the code rather than copy/paste, but if I put the code in another template, I 
get the compiler error.

Reply via email to