1008 B
1008 B
- 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
Defining useSomeFeature
- Do it when you compile:
$ nim c -d:useSomeFeature myApp
- Put it in the local
nim.cfg
filedefine:useSomeFeature
How do I echo in a {.noSideEffects.}
proc?
You can use debugEcho
for this.