Well, if you need gmatch3 then it won't do. But if gmatch1 and gmatch2 are 
enough, use C++-like approach and make those a proc which returns a structure 
with items and pairs iterators. 
    
    
    type MatchWrap = distinct seq[string]
    
    proc gmatch(src, pat: string): MatchWrap =
      let c = src.match(pat)
      MatchWrap(c)
    
    iterator items(wrap: MatchWrap): string =
      yield seq[string](wrap)[0]
    
    iterator pairs(wrap: MatchWrap): (string,string) =
      yield (seq[string](wrap)[0], seq[string](wrap)[1])
    

Reply via email to