Re: CRUNCH in CHICKEN issues

Diogo via Chicken-users <[email protected]>
Newsgroups gmane.lisp.scheme.chicken
Message-ID <[email protected]>
On Mon, Oct 20, 2025 at 11:42:59AM +0200, Felix Winkelmann wrote:
> On Sun Oct 19, 2025 at 9:56 PM CEST, Diogo via Chicken-users wrote:
> > The symbol foo is being exported in the module crunch-example, why can't I
> > access it in the top level? Am I missing something?
> 
> The mapping of exported toplevel names inside crunched code to
> qualified names in the outer Scheme environment is a bit tricky
> and may be buggy, I'll investigate this. In the meantime you can
> move the crunching into the module, as a workaround, which is
> also (IMHO) somewhat more in the style as this is intended to be
> used:
> 
> (module crunch-example (foo)
>   (import (scheme base))
>   (import (crunch))
>   (crunch (define (foo) 123)))
> 
> (import (scheme write))
> (import crunch-example)
> (display (foo))
> (newline)

I will try this. By intended style, you mean crunching small pieces of
code in a larger chicken program/module?

Probably I am stretching crunch beyond its intended use. This demo
project has a few crunch modules such as ps2-decoder, matrix-scanner,
usb-serial, etc for a microcontroller firmware. The modules are
defined in separate files and imported in a main.scm, which again
is a crunch program. All compiles ok. No chicken, only crunch.

Most modules can also be compiled to the host architecture (amd64)
and I wanted to test them there.  The intent of importing crunch
modules in chicken was to have some nice unit testing.

Alternatively, I could split the modules in implementation (.scm)
and module definition (.sld) and include the former in the latter.
Then in the chicken tests, I could  (crunch (include "former.scm")).
Not sure if that would help though. What would be your recommendation?

> > (error ...) does not do what I'd expect. Consider this example:
> 
> As siiky pointed out, the argument must be a string. I will clarify
> this in the docs.

Yeah, my bad. Thanks to you both.

Cheers,
-d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.