On Wed, Dec 03, 2025 at 06:11:49PM +0100, Felix Winkelmann wrote:
> Thanks a lot, this fixes indeed a bug and has been applied in version
> 0.993, which is now hosted on codeberg:
>
>     https://codeberg.org/Bunny351/crunch

Thanks for applying the patch and also adding the feature of auto including
the .c file. That works nicely!

I have submitted another one-liner patch, this time to codeberg. It ensures the
function names are mangled when emitting wrappers.

One question/suggestion about wrapper module naming:

Let's say we have a module foo that is crunched. It is in file foo.scm.
To use it in crunch-only programs, we emit a foo.import.scm.
To use it in scheme programs, we emit the wrappers we have discussed before.
And those wrappers need to have their .import.scm. All a bit confusing at first,
but quite understandable in hinsight.

The sequence of operations would be:

    chicken-crunch -J -emit-wrappers foo.wrap.scm foo.scm -o foo.c
    csc -J -s foo.wrap.scm      # create CHICKEN wrap module
    csc -s foo.import.scm       # create CRUNCH import module
    csc -s foo.wrap.import.scm  # create CHICKEN wrap import module

Now we have two versions of the library and I think they should have *different*
names. But -emit-wrappers give the same name "foo" to the module defined in
foo.wrap.scm.

With two different names I could do this:

;; some crunch-only code:
(import foo)

;; some chicken code:
(import (foo wrap))

The only change that would be necessary is to derive the module name from the
emit-wrapper argument instead of using that of the wrapped module.

What do you think?

Have a good weekend.

Best,
-Diogo


Reply via email to