So just to start, I am very new to nim I started reading about it and programming in it 4 days ago. I understand that using static like this

static:
  var some_variable = 10
evaluates the statement at compile time and uses the Nim VM to do that

my questions are, is there a way to use these static variables outside of the module they are defined in, and does anyone know where static is defined so i can look at how it is coded so that if my first question results in no I can possibly recreate a version of static that could

2018-01-10 02:34:14

is there a way to use these static variables outside of the module they are defined in

Sure, just give them an export marker. (The asterisk.)

2018-01-10 07:35:37
thanks, I think i learned I have a completely different problem then what I thought was going on, I will try to figure it out before I bother more people about it, but what is happening is that a proc I have made is using static variables defined in one module, but when I export that proc and use it in another module I am getting an error saying it cannot evaluate my static variable at compile time. that is why I thought the issue was that they didn't export out of modules 2018-01-10 16:27:53

Here I have made an example of what is happening

#module A

static:
  var test=0

proc test_proc(): void {.discardable,compileTime.} =
  var a = test
  echo a

#module B

import A

static:
  test_proc()

this will give me an "Error: cannot evaluate at compile time: test" for line 6 of module A

2018-01-10 16:36:28
Looks like you need a compileTime var:
var test {.compileTime.} = 0
2018-01-10 18:59:17
Awesome Thank you, that worked great 2018-01-10 19:17:32
Bizarre enough, the following seems to work:
#module A

static:
  var test=0

proc test_proc(): void {.discardable,compileTime.} =
  var a = test
  echo a

static:
  test_proc()
#module B

import A

static:
  test_proc()
2018-01-10 22:38:08
yeah I have noticed that too, might be a bug... I wouldn't know how to go about stating that though 2018-01-14 00:02:46