Originally I implemented gnc:load to get things started, but I only
intended it to be a lower level mechanism to be used in cases where we
knew that the file being loaded would only be loaded once.

In most cases, you want a file to be loaded iff it hasn't already been
loaded.  That way two files that depend on the same other file won't
cause the other file to be loaded twice.  Aside from the efficiency
issues, loading a file twice can be dangerous if the file does any
one-shot initialization.

So I'm planning to add (gnc:depend "filename") and (gnc:support
"filename").  You call the former if your source needs the code
provided by the other file and the latter if the file supports it.
This will be an extremely simple mechanism, only based on filenames.
I.e. we'll have in some source file:

  (gnc:depend "balance-sheet-utils.scm")

and then in balance-sheet-utils.scm:

  (gnc:support "balance-sheet-utils.scm")

These will be built on top of gnc:load so they'll handle all the
expected path searching.

Also, everyone should note that it's perfectly acceptable for both
these functions and for gnc:load to use partial paths, and I encourage
this whenever it helps organize the code.  For example:

  (gnc:load "report/balance-sheet.scm")
  (gnc:load "report/profit-loss.scm")
  (gnc:load "report/dummy.scm")

(Actually this isn't the best example, since RSN, I'm going to change
 it so that we have a separate search path for reports, with something
 like (gnc:load-report "balance-sheet.scm"), which will be implemented
 something like this:

  (define (gnc:load-report name)
    (gnc:load name gnc:*report-path*))

 but for now, I'm just doing the easiest thing.)

-- 
Rob Browning <[EMAIL PROTECTED]> PGP=E80E0D04F521A094 532B97F5D64E3930

--
Gnucash Developer's List 
To unsubscribe send empty email to: [EMAIL PROTECTED]

Reply via email to