How to use an egg in a compiled environment?

This is a continuation of my previous question . Unfortunately, it seems that Chicken Scheme does not support complex numbers by default, but offers the numbers egg, which can be set.

I installed this egg through chicken-install numbers , and I can download it in an interpreted environment. I can do this by calling use ; either manually in REPL, or by running my .scm file as a script via csi .

For example, this script works fine:

 (use numbers) (begin (display 3+3i) (newline) ) 

when starting with:

 csi -s main.scm 

But when I compile this exact fragment with csc (even without any additional flags), I get the same runtime error as I would if I hadn’t downloaded it (for example, an unbound variable). In a compiled environment, use doesn't seem to cut mustard.

Two other things to note are that in the documentation I tried other import functions like require-extension , require-library , etc., but none of them matter. The other is that if I change the module name to something other than numbers , say numberss , it will not be able to compile, complaining that it cannot load the extension, so obviously, at least it detects that numbers .

Can someone explain, preferably with a short working example, how to use an egg in a compiled environment? Thank you in advance!:)

+4
source share
1 answer

According to the helpful information provided by Peter Becks on the mailing list , most eggs will work out of the box, you just need to use them.

Some eggs, however, provide extensions to the base reader, and the compiler should be informed about them. You can do this with the -X flag. According to the documentation , numbers is one of these packages.

Compiling your snippet with:

 csc -X numbers-syntax main.scm 

worked fine.

Hope this helps! :)

+5
source

Source: https://habr.com/ru/post/1448006/


All Articles