Thanks a lot for the answers in here, made the questions clear! Still without
understanding the "untyped" one tho.
Thanks!
About templates, they're like C macros, a simple way to do metaprogramming
without manually building syntax like in Nim macros. They're not like procs in
that they aren't called at runtime, they simply exist during compile time and
transform AST given to its parameters. An `untyped` parameter is
To use C code in Nim I compile the C files with -c option (on GCC), then I use
{.link: "your_binary.o".} pragma in Nim files and simple {.importc.} for each
function or type. Maybe there is uses cases where importing headers is
necessary but I haven't encontered this case for the moment. (maybe
My own spin:
1\. Object are allocated on the stack while ref objects are allocated on the
heap by the garbage collector. `let a = foo` will copy the object in the first
case but will copy the reference to the object in the second case, so `a` and
`foo` are completely distinct for object but the
I'll answer to best what I know
* 1\. object is preferable if you want value-type, while ref object is for
reference-type (it's obvious from the name tho, ). I usually use
reference-type when it's costly to create it such as IO, Files, memory etc.
When using ref object, new is required altho
Hello!
Been using nim for a few days, been reading a lot and feel really happy right
now!
Few questions (I myself come from high level languages although I've used few c)
1\. What is best to use: ref object or object and why. If using ref object, is
"new" always needed?
2\. What's the differe