chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] (load ...)


From: Graham Fawcett
Subject: Re: [Chicken-hackers] (load ...)
Date: Thu, 7 Jun 2007 21:41:48 -0400

On 6/7/07, Peter Keller <address@hidden> wrote:
On Thu, Jun 07, 2007 at 04:01:13PM -0400, Graham Fawcett wrote:
> Example:
>
> ;;; a.scm
> (define (hello) (print "hello from A!"))
>
> ;;; b.scm
> (use a)
> (hello)
>
> Now, run "csi -b b.scm" and you'll see:
> ; ...
> ; loading b.scm ...
> ; loading ./a.scm ...
> hello from A!

[snip]

> Does this help?

So in this example, a.scm is analyzed and compiled by the compiler and
not interpreted?

No. a.scm is loaded and interpreted. Even if you compile b.scm into an executable, the "b" executable will include the evaluator, and it will evaluate (interpet) a.scm. Compilation is *always* explicit, via csc. You would have to call "csc -s a.scm" first to create a shared library (at which point you could delete a.scm if you wished).

If you really wanted to, you could compile b.scm without the evaluator, in which case "a.scm" would fail to load (because there would be no procedure available to evaluate it). See the FAQ on "smaller executables". Chances are that you don't want to do that.

Can you do things like (define feh use)? Or is (use ...) like #include
for C?

Well, that's not an either/or question. :-) But use/require-extension is syntax, and it is not first-class; so you cannot bind a variable to it, like you can with a function or simple value. So no, (define feh use) will not work. Since (use) works at runtime, and is fairly intelligent about how it determines what to load, it cannot be equated to #include.

Having said all that, whatever you are trying to accomplish is likely possible. Are you just feeling out your options, or do you have a specific problem in mind?

Graham


reply via email to

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