Nim is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority).
quote do
here and there, but haven't used/understood it yet
a
is IntLit
- don't know how to pass that to a proc which creates an instance of Shape
, there is no IntLit
type!?
quote do
, something like what you did there and a lot of hardcoded things (:P), you can do something like this: http://ix.io/1mps/nim
quote do
is something i really need to start using :)
dumpAstGen
, i now have a new best friend!
NimNode
. e.g. refactoring the above to: http://ix.io/1mpu/nim
this is a minimum reproducable example without dependencies to see what I mean with leaks: https://gist.github.com/tim-st/30eb88b2a96fdd77623be945dff5fc2a
yep, I'm playing around with this code and notice that on every request there is at least 3 allocations for response body (each of them ~equal a body size) and the memory only for 2 of 3 allocations is deallocated later
logAlloc = true
and call GC_full_collect
before each request
Hello, What is a good example of when to use reference types
vs non-reference types
?
Here is a non-ref object:
type
Person = object
name: string
age: int
var person: Person
person.name = "Daniel"
Here is a ref object:
type
PersonObj = object
name: string
age: int
PersonRef = ref PersonObj # reference type
proc setName(name: string, person: PersonRef) =
person.name = name
var person1 = PersonRef()
setName("Daniel", person1)
Why should I use one over the other? They both seem to be achieving the same thing.
Since ref object is live on the heap, and non-ref is on the stack, Is that the only difference?