git.m455.casa

m455.casa

clone url: git://git.m455.casa/m455.casa


posts/i-finally-learned-how-to-make-chicken-scheme-modules-lol.txt

1 title: i finally learned how to make chicken scheme modules lol
2
3 2023-07-29 22:22
4
5 i put off learning how to make chicken scheme modules since i got into chicken
6 scheme because the examples on the docs never worked for me. i think this was
7 because, from the best of my memory, i was trying to interpret a scheme file
8 that imported a module i made, but i hadn't generated the object files for the
9 imported module. it kind of sucks that you have to do this, but i'm all for
10 fucking around and finding out, so i didn't mind too much, and proceeded to
11 write a makefile to automate some of this, and clean up the generated object
12 files after compilation completed.
13
14 for example, if you have a `utils.scm` file, which is a module, you need to
15 first generate an object file for it by doing this:
16
17 ```
18 csc -c -static -J src/utils.scm -unit utils -o utils.o
19 ```
20
21 then you can do the whole (import utils), and use shit from that.
22
23 i also found it weird that my main file that is importing things had to be a
24 module too. oh well i guess.
25
26 this kind of led me to converting all of my module-like files, which were just
27 imported to my main files using includes (lol), to actual scheme modules. it
28 ended up being a little overkill makefile-wise to have separate
29 `generate-posts-page`, `generate-html`, and `generate-rss` modules, so i decided
30 to combine them all into a generate.scm file.
31
32 anyway, this post is mostly a "yay" post because chicken scheme modules always
33 got the best of me. funnily enough though, i'm actually rewriting my website
34 generator in fennel (again), so there wasn't much point in me converting all my
35 scheme shit to module, except for the fun learning part of it. hmmmm i actually
36 think i already mentioned in my last blog post that i'm starting another website
37 generator in fennel... i'm too lazy to look so i'll just leave these words here
38 for you to read lol. i'm mainly doing it in fennel because i like how small
39 fennel is, and i like how clean the creation of modules feels. plus, i miss just
40 using an interpreted language. like, i mean, i can interpret chicken scheme
41 code, i just like using its compile feature too much, so i mostly just use
42 that.
43
44 you can check out the `Makefile` and `src/generate.scm` file on this website's
45 [https://git.m455.casa/m455.casa/html/files.html|source] if you are curious
46 about how i generate object files for modules, and how i compile static binaries
47 for my website generator and local web server in chicken scheme.
48