Tips and tricks
Clone this wiki locally
- Use "nim check myfile.nim" to check your program for errors, without code generation. This makes the process quicker.
Using reserved words as identifiers
You can use the slanted quote string syntax if you need to use a reserved word as an identifier:
var `type`: int
Tricks with conditional compilation
when defined(useSomeFeature): const someSubFeature = true type ID_Type = int32 var defaultUserName = "Frank" else: type ID_Type = int16 var defaultUserName = "Molly" # `when` does not open a new scope, so `ID_Type` and `defaultUserName` # are available here. when isMainModule: #this code is ran only when this module is the main compilation module echo "This module was compiled on ", CompileDate, " at ", CompileTime
- Do it when you compile:
$ nim c -d:useSomeFeature myApp
- Put it in the local
How do I echo in a
You can use
debugEcho for this.