Updated Tips and tricks (markdown)

This commit is contained in:
Billingsly Wetherfordshire 2014-05-01 11:13:57 -07:00
parent 724573688b
commit 301aa446f4
1 changed files with 16 additions and 4 deletions

View File

@ -7,14 +7,26 @@ You can use the slanted quote string syntax if you need to use a reserved word a
## Tricks with conditional compilation
```nimrod
const someFeature = True
when someFeature:
when defined(useSomeFeature):
const someSubFeature = true
type ID_Type = int32
var defaultUserName = "Frank"
else:
const someSubFeature = false
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: `$ nimrod c -d:useSomeFeature myApp`
* Put it in the local `nimrod.cfg` file `define:useSomeFeature`
## How do I echo in a ``{.noSideEffects.}`` proc?
You can use ``debugEcho`` for this.