3
$\begingroup$

I think I read somewhere that Needs is the recommended way to import dependencies, but I usually see << used in examples. The documentation seems to be saying that << is just alternative syntax for Get. The documentation for Needs says that it calls Get, but does not explicitly say whether or not it does anything else and what that might be. Is there a more more precise statement of the relation between these somewhere?

$\endgroup$
  • 2
    $\begingroup$ Get and << are the same thing as far as I know. Needs calls Get only if the package was not loaded already. If the package is already loaded, then Needs is smart enough to know this and will not reload it. Sometimes reloading the same package again might cause a problem (that is what I read somewhere). Not sure of why and how. So, it is better to use Needs I would think, just in case the package itself was not designed to be aware of itself being loaded before, or it assumed it was not loaded. I think a well designed package should not cause a problem with multiple Get. $\endgroup$ – Nasser Mar 30 '14 at 13:31
  • $\begingroup$ I seem to remember learning somewhere that Needs will let Mathematica know the names that are publicly declared in the package (typically by means of ::usage message definitions), even though their definitions are not yet available. Is this incorrect? $\endgroup$ – murray Mar 30 '14 at 15:10

Browse other questions tagged or ask your own question.