Accessing object properties where objects are in a sequence

2021-09-22 Thread Stefan_Salewski
Your assumption is generally right, but only when you use only clean Nim code. Not when you use C libs, casts, addr() and pointers. With the later you can do very dirty things, you can un-intentionally overwrite references for example. And then, when the the GC tries to free memory pointed to by

Accessing object properties where objects are in a sequence

2021-09-22 Thread Neil_H
Well i would have thought that the end result of all garbage collectors is the same... to free up memory that is no longer being used? So how can a garbage collector that stomps all over memory that is obviously still being used be correct? The most annoying thing is the fact that my code seeme

Accessing object properties where objects are in a sequence

2021-09-22 Thread Stefan_Salewski
Yes, we saw your update. But your main conclusion is wrong with a large probability, it is not a bug of the GC. When our C code crashes when we call dealloc() or free(), then generally the bug is not in these two functions, but in our own code. Nim's various garbage collectors has been already

Accessing object properties where objects are in a sequence

2021-09-22 Thread Neil_H
Updated above

Accessing object properties where objects are in a sequence

2021-09-22 Thread Neil_H
The problem is the garbage collector! If i switch it off then my app runs without crashing (reason for crashes given above)... its using 3GB of ram though which is obviously no good any suggestions on how to procede?

Accessing object properties where objects are in a sequence

2021-09-21 Thread Neil_H
Unfortunately switching to -d:release crashes the app without any error messages or gives me this error message then crashes: Error: SIGSEGV: Illegal storage access: (Attempt to read from nil?) Run The same code works without crashing or any error messages when not usi

Accessing object properties where objects are in a sequence

2021-09-16 Thread ynfle
`-d:release` does not turn off bounds checking. You can see this by looking at the `nim.cfg` for your nim installation (for choosenim,``~/.choosenim/toolchains/nim-1.4.8/config/nim.cfg``) 74 │ @if release or danger: 75 │ stacktrace:off 76 │ excessiveStackTrace:o

Accessing object properties where objects are in a sequence

2021-09-16 Thread Neil_H
No, im using the default Code Runner in VSCode which is this: nim compile --verbosity:0 --hints:off --run filepath.. Run I need debug info in there anyway since my program is in its early stages, plus i'm not sure if -d:release turns off bounds checking

Accessing object properties where objects are in a sequence

2021-09-14 Thread Neil_H
Well i already switched to object variants and everything seems to be working fine, the only thing i did notice was a slight increase in memory usage. But i will definitely have a look at your code, thanks for replying.

Accessing object properties where objects are in a sequence

2021-09-14 Thread ynfle
Are you using `-d:release`?

Accessing object properties where objects are in a sequence

2021-09-10 Thread ftsf
Hi there, this is a thing that's a little bit harder in Nim than some other languages, but here's how you can do it without switching to object variants. import json type Base = ref object of RootObj a: int Child = ref object of Base b: int

Accessing object properties where objects are in a sequence

2021-09-10 Thread Neil_H
Well, switching my program from using standard Objects to Object variants has proved a good move so far, i am able to use Json to save the objects and restore them very easily. The only downside i came across was when passing an object variant to a procedure, Nim would not allow me to use the v

Accessing object properties where objects are in a sequence

2021-09-07 Thread Stefan_Salewski
Thanks. There are some more still: Will fix them soon, or replace by others :-)

Accessing object properties where objects are in a sequence

2021-09-07 Thread xigoi
You have a typo in the book: `s/type save/type safe`

Accessing object properties where objects are in a sequence

2021-09-07 Thread Neil_H
Hi Stefan, yes, object variants could be a solution however i am not sure that each instance taking the same ram as the largest one bodes well for my use case since certain objects may need to hold a sizeable amount of text (say 500 chars) where as other instances may only need to hold 1 charact

Accessing object properties where objects are in a sequence

2021-09-07 Thread Neil_H
You have convinced me to have a look at Object variants first.

Accessing object properties where objects are in a sequence

2021-09-07 Thread Stefan_Salewski
> certain objects may need to hold a sizeable amount of text (say 500 chars) > where as other instances may only need to hold 1 character. Note that a Nim string is a value object with a data buffer allocated on the heap for the actual text data. So sizeof(myStringInst) should be a small value,