Hi Mario,

Thank you! I really love how kind and helpful the CHICKEN community is — 
definitely one of the huge draws to using CHICKEN!

> Usually you should see some warnings that may lead to "module
> unresolved" errors.

Turns out I hadn’t updated my modules.db, so I wasn’t seeing the suggested 
imports. Since they were warnings, I was ignoring them. I’m used to messages 
that explain compilation errors as being marked as “error” instead of 
“warning”. But now that I can see the suggested imports, it’s much more obvious 
how to fix the issue :) Your patch fixed the issue.

>> Why would compiling into a module cause an error when my functions
>> work fine in the REPL? Any help would be appreciated.
> 
> That's because the interpreter implicitly loads some modules, and the
> compiler doesn't do that.

That’s odd; I would expect both to implicitly load those modules because the 
documentation for both data-structures 
<https://wiki.call-cc.org/man/4/Unit%20data-structures#unit-data-structures> 
and ports <https://wiki.call-cc.org/man/4/Unit%20ports#unit-ports> say 
both modules are "used by default, unless the program is compiled with the 
--explicit-use option”, which I was not using (at least intentionally).

But at least now I know! Thank you so much,

Michael


> On Jun 14, 2016, at 3:12 PM, Mario Domenech Goulart <[email protected]> 
> wrote:
> 
> Hi Michael,
> 
> On Tue, 14 Jun 2016 11:09:09 -0400 Michael Silver <[email protected]> 
> wrote:
> 
>> I’m new to CHICKEN and I’m working on converting a large Guile
>> codebase to CHICKEN.
> 
> Welcome!
> 
>> The codebase is a collection of shared libraries (each library in a
>> separate .scm file), collectively known as “lab-core”. So, I’ve
>> packaged it all as an egg called “lab-core” with each individual .scm
>> file as it’s own module (under different names).  Does this seem like
>> a reasonable way to package such a project?
> 
> Sounds good to me.
> 
>> As I go file by file converting to CHICKEN modules, I keep running
>> into “module unresolved” errors when attempting to install my egg via
>> chicken-install.
> 
> Usually you should see some warnings that may lead to "module
> unresolved" errors.
> 
> When I try to compile your example, I get:
> 
>  Warning: reference to possibly unbound identifier `string-chomp' in:
>  Warning:    port-puts
>  Warning:    suggesting: `(import data-structures)'
> 
>  Warning: reference to possibly unbound identifier `with-output-to-string' in:
>  Warning:    port-puts
>  Warning:    suggesting: `(import ports)'
> 
>  Error: module unresolved: loglevel
> 
> That means:
> 
> * in `port-puts' you are using `string-chomp', which is exported by the
>  data-structures module, but you are not importing it.
> 
> * in `port-puts' you are using `with-output-to-string', which is
>  exported by the ports module, but you are not importing it.
> 
> So, all you need to do is:
> 
> $ diff -u loglevel.scm.orig loglevel.scm
> --- loglevel.scm.orig   2016-06-14 21:08:03.547764310 +0200
> +++ loglevel.scm        2016-06-14 21:08:13.711763790 +0200
> @@ -1,6 +1,6 @@
> (module loglevel *
>  (import chicken scheme)
>  -(use srfi-1)
>  +(use data-structures ports srfi-1)
> 
> 
> ;; Expected behavior:
> 
> 
>> Unfortunately, the output gives no indication of which function is
>> causing the error or why, and the only way I’ve been able to figure
>> this out is by commenting out chunks of code and narrowing down until
>> I find the offending function. If I delete that function, the module
>> compiles perfectly and I can use the rest of the functions just as you
>> would expect. What does "module unresolved” mean and is there a better
>> way to figure out what is causing it?
> 
> Do you see the warnings in the compiler output?
> 
>> I’ve attached a MWE where loglevel is a stripped-down version of one
>> such library causing the “module unresolved” error. Here are the steps
>> to reproduce:
>> $ cd lab-core
>> lab-core$ chicken-install -debug
>> (see attached output.txt for the debug output)
>> 
>> Compare this to:
>> $ csi
>>> (load “loglevel-no-module.scm”)
>>> (err-puts "foo" 42 "!”)
>> foo42!
>> “!"
>> which shows my functions working perfectly as long as I’m not using
>> module syntax.
>> 
>> Why would compiling into a module cause an error when my functions
>> work fine in the REPL? Any help would be appreciated.
> 
> That's because the interpreter implicitly loads some modules, and the
> compiler doesn't do that.
> 
> All the best.
> Mario
> -- 
> http://parenteses.org/mario

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to