I am writing a package where a couple defined functions take a very long time define at initialization time (because they are large CompiledFunction
s).
However since these functions are not meant to be used frequently, I would like to defer making its definition until the user calls it the first time.
Suppose my package looks like this:
BeginPackage["MyPackage`"]
BigFunction::usage = "BigFunciton[a,b] computes a+b.
But, this function will initialize only when it is first called.";
Begin["Private`"];
(*Need to delay this definition until it is first called.*)
BigFunction = Compile[{{a,_Real},{b,_Real}},a+b];
End[];
EndPackage[]
How do I delay the definition of the function BigFunction
until it is first called by the user?
BigFunction := BigFunction = Compile...
$\endgroup$ – halirutan♦ Oct 1 '15 at 13:05