1
2
Fork
You've already forked forth.fnl
0
A little toy FORTH in Fennel. Basically just a calculator.
  • Fennel 84.2%
  • Forth 15.8%
Find a file
2026年06月22日 10:32:02 -04:00
.gitignore Simplify arithmetic 2026年04月10日 17:32:15 -04:00
examples.forth Hello, world 2026年06月22日 10:32:02 -04:00
forth.fnl Accept file as an argument 2026年06月22日 10:27:54 -04:00
LICENSE Add license 2026年04月10日 20:51:02 -04:00
README.md Hello, world 2026年06月22日 10:32:02 -04:00
spellbook.forth Chevrons look a bit nicer compared to quotes 2026年06月22日 10:03:27 -04:00

forth.fnl - basically a calculator

This is a toy FORTH-like with a whole lot of Fennel in the soup. It's meant to help me understand the language and to have fun, too! This is meant to be used as a personal calculator so it might just be useful for me, but feel free to take what you need from it!

This is also being written by someone who's in the process of learning FORTH so this implementation is quite possibly composed of sins and tragedies in the eyes of actual FORTH programmers.

Running

To run, install Lua and Fennel. Try out the example file:

$ fennel forth.fnl examples.forth

What it can do

Import the standard library and print out a string:

« spellbook.forth » import
« hello, world! » say

You can define arbitrary words which can act as functions for your program.

( This is a comment )
: width 20 ;
: height width ;
: area width height * ;

( Print the result )
area say

It has some built-in words for calculations:

( Convert celsius to fahrenheit )
24 temp.celsiusToFahrenheit say
( Convert miles to kilometers )
15 dist.milesToKilometers say

You can print the stack by using the word stack.

You can also create variables:

( This defines the variables )
variable month
variable year
variable date
( Set multiple values by defining a word )
: setDate year ! date ! month ! ;

7 31 3 setDate
( Print multiple values by defining a word )
: showDate month @ « / » .. print
 date @ « / » .. print
 year ? ;

« The set date is » print showDate

License

ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4)

This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles.

No AI

No AI was involved in making this. Fuck that.