If I define a module as such:
module Module1
open System
let foo =
Console.WriteLine("bar")
Then, in interactive do
#load "Library1.fs" //where the module is defined
open Module1
I see a
[Loading c:\users\jj\documents\visual studio 2015\Projects\Library1\Library1\Library1.fs] bar
Indicating that the foo function ran without me even calling it!
How/why does this happen? Is there any way to prevent it?
I'm aware that the return value of foo is whatever (Console.Writeline("bar")) evaluates to, and that there isn't any reason that can't be evaluated "immediately?" (when the module is loaded I guess?) - but is there a way to prevent it from happening? If my module functions alter the state of some other stuff, can I ensure that they do not evaluate until called?