chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] use vs uses?


From: John Cowan
Subject: Re: [Chicken-users] use vs uses?
Date: Sun, 31 May 2015 11:50:31 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

chi scripsit:

> (use a) versus (declare (uses a)) what's the differences between those?

(use a), which can also be written (require-extension a), is the regular
way of bringing in code and making identifiers available in the current
environment.  It first does a "require-library", which checks whether
the library "a" has already been loaded, and if not, loads it (that
is, "a.scm", "a.so", "a.dll", or "a.dylib").  Then it imports all the
identifiers of a module named "a", which is presumed to have been loaded
by the library "a", though this is not actually required.

The (declare (uses a)) form is for use with the unit system, which
precedes the module system as a method of code organization.  It is
pretty much only used internally to Chicken nowadays.

> (use a) will load module...library...module... what do you call the
> thing that (use) loads? Is it a library or a module?

Both: see above.

> But (import) imports modules that are already loaded from libraries. 

Correct.

> Are libraries and modules equivalent?

No.  A library is normally a file, though there are some libraries
that are built in to Chicken:  see
<http://wiki.call-cc.org/man/4/Non-standard%20macros%20and%20special%20forms#require-library>
for details.  A module is a Scheme form (module name ...).

> Can a library have more than one module?

Yes, although I advise against it.

> If a library has more than one module, then how does (use amodule)
> know to load the same library as (use bmodule)?

It doesn't.  These will try to load different libraries.  If you have
two modules in the same library, you can't use "use"; you have to use
"require-library" and "import" separately.

> Do modules have to be named after libraries?

No, but "use" relies on it.

> What's the difference between a module inline in your code and
> a library?

Nothing, except that you can't import an inline module with "use",
only with "import".

In R7RS mode, the rules are different:  "import" does what native Chicken
"use" does, and module names are lists of symbols that are converted
into library names thus:  module (foo bar baz) corresponds to library
"foo.bar.baz".

-- 
John Cowan          http://www.ccil.org/~cowan        address@hidden
You know, you haven't stopped talking since I came here. You must
have been vaccinated with a phonograph needle.
        --Rufus T. Firefly



reply via email to

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