Eval_file vs load_module vs use



Congrats for your hard work on ChaiScript.

I would like to get a good understanding of the differences between load_module vs use and eval_file.

As I understand it now:

  • eval_file will always evaluate the file, no matter it was loaded before.
  • use will see if the file was loaded, if it was already, it will not evaluate.

So I wonder, what is load_module for? Any other explanations in further differences is welcome, I am not sure the approach I should take for my project depending on the kind of script I load:

  • a script meant to be a module to reuse. I guess I should use ‘use’ or ‘load_module’
  • a script meant to be executed. (can parameters be passed to scripts?). I guess eval_file should be the correct answer here.

Thank you very much for your time.


i don’t think load_module loads scripts, rather binary modules. i haven’t used it yet though.
but about use and eval_file you’re right i think. so my guess would be:

  • use for scripts to be executed once (you could call these modules or includes in a way)
  • eval_file to just execute some script
  • load_module to load binary module to extend your engine.