in reply to Re: Re: Re: Re: Confused about splitting program into multiple files.
in thread Confused about splitting program into multiple files.

...if every function is going to be available (exported) is there a reason not to put them in package main?

One reason could be code reuse. If the same functions are used across several scripts, you at minimum save a little typing by keeping them in a separate file where they can be pulled in by all the scripts that need them.


Dave

  • Comment on Re: Re: Re: Re: Re: Confused about splitting program into multiple files.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Confused about splitting program into multiple files.
by Anonymous Monk on Feb 15, 2004 at 09:09 UTC

    I think you missed the point here. We are already discussing a separate module that can be used by any script. The question is, if that module exports every function within, why not simply make the package name 'main' and not bother exporting?

    The answer is: because that forces your decision upon all users of the module. If you at least use a separate package name I can avoid your auto-exportation of everything by doing: use YourMod();. Or maybe I want to use your module from another package (have your module export into a different namespace). If you write your module to simply define everything inside of package 'main', you've removed all my options.