let variable is not gc safe

2022-07-30 Thread mildred
Being global variables, their lifetime should be infinite, so I believe the must always be gcsafe. Is that the compiler that does not understand that global variables cannot be garbage collected?

let variable is not gc safe

2022-07-29 Thread jrfondren
Another option, if this is a microservice where changes in configuration can come with a recompilation: const SERVER_HOST* {.strdefine.} = "localhost" SERVER_PORT* {.intdefine.} = 5000 proc test {.gcsafe.} = echo (SERVER_HOST, SERVER_PORT) when isM

let variable is not gc safe

2022-07-28 Thread ynfle
let is immutable, as the address of the variable can be taken. Once an address is received, it can outlive its lifetime

let variable is not gc safe

2022-07-28 Thread Cnerd
So after going through the nim manual i found out that you can overide the compilers gc safe analysis to assign non gc safe variables to local proc variables like so {.cast(gcsafe).}: let SERVER_HOST = SERVER_HOST SERVER_PORT = SERVER_PORT

let variable is not gc safe

2022-07-28 Thread Cnerd
I have these let variables from os import getEnv from strutils import parseInt, isEmptyOrWhitespace let SERVER_HOST* : string = block : var host : string = "localhost" ## default host localhost let env_host = getEnv("H