3

If you have 2 Python files in the same directory, you can do the following:


something.py

def returnSomething():
    return True

index.py

from something import returnSomething

test=returnSomething()

Can something similar be done in Nim by calling their procs?

ad absurdum
  • 19,498
  • 5
  • 37
  • 60
Anthony
  • 33
  • 1
  • 3

1 Answers1

9

Yes, you can, you just need to export the proc by adding * (the export marker) after the name of it - https://nim-lang.org/docs/manual.html#procedures-export-marker :)

# something.nim
proc returnSomething*(): bool = 
  result = true
# index.nim
import something

test = returnSomething()

You can also replace import something with from something import returnSomething, but it's a personal preference.

I think it might be good for you to read https://narimiran.github.io/nim-basics/ which covers most of Nim basics :)

Optimon
  • 723
  • 1
  • 8
  • 17