Note that `ref` stands for "reference", not "reference counting". The behavior
will not differ between the reference counting and the mark and sweep GC.
You also do not strictly require `ref` for polymorphism to work, though this is
the most common use case; any kind of pointer (`ref`, `ptr`,
The forum has been updated. New users are now moderated. It's also much faster
now.
As far as I know, cstring is just a pointer to the char's array. The inner
representation of the string type contains such kind of array, so the converter
just passed the array pointer from the inner representation without any
nil-checks to your test procedure.
Probably the converter should
proc test(x: cstring) = echo cast[int](x)
var str: string = nil
test(nil) # output 0 -> correct
test(str) # output 8 ??
I think this should be a bug.
I use "Nim Compiler Version 0.15.2 (2016-10-23) [Windows: i386]"
Cross module inline procs are inlined across modules without link time
optimization, the Nim compiler duplicates the inline procs in the generated C
code.