Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ Note: these are general guidelines, not hard rules; there are always exceptions.
Code reviews can just point to a specific section here to save time and
propagate best practices.

.. _define_needs_prefix:
New `defined(foo)` symbols need to be prefixed by the nimble package name, or
by `nim` for symbols in nim sources (e.g. compiler, standard library). This is
to avoid name conflicts across packages.

.. code-block:: nim

# if in nim sources
when defined(allocStats): discard # bad, can cause conflicts
when defined(nimAllocStats): discard # preferred
# if in a pacakge `cligen`:
when defined(debug): discard # bad, can cause conflicts
when defined(cligenDebug): discard # preferred

.. _noimplicitbool:
Take advantage of no implicit bool conversion

Expand Down
2 changes: 1 addition & 1 deletion lib/system/memalloc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ when hasAlloc and not defined(js):
let stats2 = getAllocStats()
echo $(stats2 - stats1)

when defined(allocStats):
when defined(nimAllocStats):
var stats: AllocStats
template incStat(what: untyped) = inc stats.what
proc getAllocStats*(): AllocStats = stats
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tbintree2.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
cmd: '''nim c -d:allocStats --newruntime $file'''
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
output: '''0
(allocCount: 6, deallocCount: 6)'''
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tgcdestructors.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
cmd: '''nim c -d:allocStats --newruntime $file'''
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
output: '''hi
ho
ha
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tnewruntime_misc.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
cmd: '''nim cpp -d:allocStats --newruntime --threads:on $file'''
cmd: '''nim cpp -d:nimAllocStats --newruntime --threads:on $file'''
output: '''(field: "value")
Indeed
axc
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tnewruntime_strutils.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
valgrind: true
cmd: '''nim c -d:allocStats --newruntime -d:useMalloc $file'''
cmd: '''nim c -d:nimAllocStats --newruntime -d:useMalloc $file'''
output: '''
@[(input: @["KXSC", "BGMC"]), (input: @["PXFX"]), (input: @["WXRQ", "ZSCZD"])]'''
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tsimpleclosure.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
cmd: '''nim c -d:allocStats --newruntime $file'''
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
output: '''a b
70
hello
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tv2_raise.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
valgrind: true
cmd: '''nim c -d:allocStats --newruntime $file'''
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
output: '''OK 3
(allocCount: 8, deallocCount: 3)'''
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/twidgets.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
cmd: '''nim c -d:allocstats --newruntime $file'''
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
output: '''button
clicked!
(allocCount: 4, deallocCount: 4)'''
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/twidgets_unown.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
cmd: '''nim c -d:allocStats --newruntime $file'''
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
output: '''button
clicked!
(allocCount: 9, deallocCount: 9)'''
Expand Down