1
$\begingroup$

So I have posted a few questions on loading packages, because it is so simple, yet always failing for me. I made a new file Streams.m in the directory ~/Library/Mathematica/Applications/, which is in $Path. This is the same directory in which Classes.m is in, which works and loads fully. I know that the command << reads in a file, and I am fairly certain I have figured out what has been causing these frustrating errors. When I open Classes.m and Streams.m in Mathematica, they look normal, nothing commented out. However, when I open Classes.m and Streams.m in vim, I get this: enter image description here enter image description here So I think it's pretty clear the reason I can load the Streams.m but not use the functions is because of the commenting, but I absolutely did not save it that way. Any ideas why it would save like this? Another odd difference is that Classes.m starts with ::Input::Initialization:: while Streams.m just starts with ::Input::. Furthermore, if I add ::Initialization:: to Streams.m and then open it, I get this:enter image description here What on earth is going on? When I create these files, I type them up in a blank notebook then do save as, and choose .m extension. Do I really have to manually go through in vim and uncomment everything? This will just happen again when I make a new package.

$\endgroup$
7
  • $\begingroup$ When you create a package from a notebook, any cell that isn't an "Initialization" cell will become a comment. $\endgroup$
    – Jason B.
    Jun 27 '20 at 20:55
  • 4
    $\begingroup$ Possible duplicate of Saving file as .m causes it to save as comments $\endgroup$
    – Jason B.
    Jun 27 '20 at 20:58
  • $\begingroup$ jeez is it that simple lol? I undid all the comments in vim and it works. Must've been that. why must it be an initialization cell? $\endgroup$
    – Brandon
    Jun 27 '20 at 21:00
  • $\begingroup$ I think the workflow is that you develop a package in a notebook, but there could be all kinds of random cells in there. So you take the cells that represent the actual package code and make them Initialization cells. I don't make packages that way, but that seems what it is made for $\endgroup$
    – Jason B.
    Jun 27 '20 at 21:09
  • $\begingroup$ how do you make packages? $\endgroup$
    – Brandon
    Jun 27 '20 at 22:54