Re: Using `{.gcsafe.}` on a global string

2019-10-08 Thread sschwarzer
I suppose the reason why I might want to override the compiler's analysis would probably _not_ be that I want to "risk it" despite GC-unsafe code. I'd use the pragma because there are - hopefully - clear rules what is GC-safe and what isn't and I'd want to override the compiler in case the code

Re: Using `{.gcsafe.}` on a global string

2019-10-08 Thread dawkot
Well, the entire point of the pragma is, according to the manual: `To override the compiler's gcsafety analysis a {.gcsafe.} pragma block can be used`

Re: Using `{.gcsafe.}` on a global string

2019-10-08 Thread sschwarzer
Re 1.: How would I be able to tell whether the code is safe in the future? Will there be a new definition of "GC-safe" at some point or was my understanding of GC safety wrong to begin with?

Re: Using `{.gcsafe.}` on a global string

2019-10-08 Thread sschwarzer
Thanks for your answers and the code suggestion. I see what you're doing here, but I need the same temporary directory for all threads. :-) Would the approach with `deepcopy` [as in the manual](https://nim-lang.org/docs/manual.html#threads-gc-safety) be safe? import os import p

Re: Using `{.gcsafe.}` on a global string

2019-10-07 Thread Araq
1. This is _currently_ safe code. I wouldn't use it. 2. No, you are on your own. 3. In the future strings and seqs should use a shared heap and be `gcsafe` out of the box. 4. I'm not aware of any such article, but here is a hint, I would code it as: import os import pos

Using `{.gcsafe.}` on a global string

2019-10-07 Thread sschwarzer
I have the following program: import os import posix_utils import strformat import threadpool let tempRootPath = mkdtemp("vppdiff") proc xmiFilePath(fileNumber: int, cleaned: bool): string = let cleanedSuffix = "_cleaned" return tempRootP