> -w is used when invoking C compiler > How could I believe a compiler that 
> can't generat clean C code?

There are test code that check correctness of Nim. 
[https://github.com/nim-lang/Nim/tree/devel/tests](https://github.com/nim-lang/Nim/tree/devel/tests)

Warnings in C compiler are for preventing C programmer making mistake. I don't 
think how people make mistake when writing C by hand and generating it from a 
programm is same. Clean C code would be important when you work with C 
programmers who read or edit your code. But Nim genereated C code is not 
supposed to be read or edit by human. Correctness and efficiency are more 
important than generating a C code easy to read for humans in Nim.

> NIM_CONST is nothing for C++

const in C++ doesn't help optimizer. 
[https://stackoverflow.com/questions/212237/constants-and-compiler-optimization-in-c](https://stackoverflow.com/questions/212237/constants-and-compiler-optimization-in-c)
 
[https://stackoverflow.com/questions/3896050/does-const-help-the-optimizer-c](https://stackoverflow.com/questions/3896050/does-const-help-the-optimizer-c)

const in C++ is for preventing programmer making mistake. I don't think it is 
important for Nim generated C++ code.

> Oh, the last and the least one, those It templates do not look fancy to me 
> now. > school.students.filterIt(it.grade == 3) > I will never use it to 
> represent a student in this example.

I think it in filterIt template stands for _iterator_ , not pronoun _it_. It is 
possible to make a filterIt template that take an identifier that is used 
insted of it. 
    
    
    template filterIt(s, name, pred: untyped): untyped =
      var result = newSeq[type(s[0])]()
      for name {.inject.} in items(s):
        if pred: result.add(name)
      result
    
    let
      temperatures = @[-272.15, -2.0, 24.5, 44.31, 99.9, -113.44]
      acceptable = temperatures.filterIt(this, this < 50 and this > -10)
      notAcceptable = temperatures.filterIt(that, that > 50 or that < -10)
    doAssert acceptable == @[-2.0, 24.5, 44.31]
    doAssert notAcceptable == @[-272.15, 99.9, -113.44]
    
    
    Run

Reply via email to