[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Understanding modules?

From: Norman Gray
Subject: Re: [Chicken-users] Understanding modules?
Date: Mon, 23 May 2016 13:37:32 +0100

John and all, hello.

On 22 May 2016, at 1:59, John Cowan wrote:

It's also worth noting that use (or
require-extension, which is the same thing) depends on the module having
the same name as the file.

Thanks: It did look as if that assumption was baked in somewhere; if the process _depends_ on the naming, then...


A module may _export_ a subset of the bindings defined in its body, making those bindings visible to other code which _imports_ the module, at compilation time. A module must be _loaded_ into a CHICKEN interpreter before its bindings can be imported; this loading can happen explicitly, or more commonly as a side-effect of some higher level expression, as below; this loading happens at run-time. In CHICKEN, the loadable object can be either the Scheme source code in a `.scm` file, or a shared object compiled with `csc -shared`.

If, as is usually the case, you compile code which depends on other modules, then you must use an _import library_; this is generated by `csc` when given the option `-emit-all-import-libraries`. In the most common case, a file foo.scm will contain a single (module foo ...) form, and the compilation should be done with `-emit-all-import-libraries`, which generates a file `foo.import.scm` named after the module. If a module uses this naming pattern, then the expression `(use foo)` (or equivalently `(require-extension foo)`) will automatically handle finding and loading the library, and importing its symbols.

The `(module ...)` form is documented below. See also the discussion of `require-extension` and `use` on <>, and possibly the discussion of `require` on <>


Best wishes,


Norman Gray  :
SUPA School of Physics and Astronomy, University of Glasgow, UK

reply via email to

[Prev in Thread] Current Thread [Next in Thread]