Many versions of Forth include a FFI that can be used to call C libraries. Raylib’s list of official bindings has an entry for gForth, but it’s 4

Adding Raylib to Forth

submited by
Style Pass
2024-10-17 19:30:09

Many versions of Forth include a FFI that can be used to call C libraries. Raylib’s list of official bindings has an entry for gForth, but it’s 4 years out of date and looks abandoned. It was created using SWIG, a tool to help generate bindings for the library.

Could I use SWIG or something like it to create new Raylib bindings? Probably, but I’m not going to do that. Instead, I’m adding the latest and greatest Raylib 5 directly to the language! This will hurt portability — this version of Forth will only be able to run on devices that can also run Raylib. Thankfully, Raylib runs on just about everything, including Raspberry Pis. Considering the purpose of Raylib, I find this is acceptable. This isn’t a Forth for embedded devices; this is a Forth to write desktop applications and video games. Maybe I should name it FunForth? ForthFun? DesktopForth? ForthUI? Hmm… I’ll ponder that later.

Take a look around the source code and see if anything stands out — or if you even understand what’s going on. (I didn’t at first!) After poking around a bit, I found this at the top of `system.fth`

Leave a Comment