33

I'm thrilled to announce the release of bjForth v0.0.3 ๐ŸŽ‰

There's been a a heap of improvements and additions compared to the last release.

What's best is that they are automatically tested every time a change is pushed ๐Ÿ˜Ž

I dare you to Grab the latest tarball and hack yourself some serious Forth ๐Ÿ˜„

you are viewing a single comment's thread
view the rest of the comments
[-] bahmanm@lemmy.ml 1 points 5 days ago

Not really I'm afraid. Effects can be anywhere and they are not wrapped at all.

In technical terms it's stack-oriented meaning the only way for functions (called "words") to interact with each other is via a parameter stack.

Here's an example:

: TIMES-10  ( x -- y )
  10 
  * 
;

12
TIMES-10
.S
120

TIMES-10 is a word which pops one parameter from stack and pushes the result of its calculation onto stack. The ( x -- y) is a comment which conventionally documents the "stack effect" of the word.

Now when you type 12 and press RETURN, the integer 12 is pushed onto stack. Then TIMES-10 is called which in turn pushes 10 onto stack and invokes * which pops two values from stack and multiplies them and pushes the result onto stack.

That's why when type .S to see the contents of the stack, you get 120 in response.

Another example is

5 10 20 - *
.S
50

This simple example demonstrates the reverse Polish notation (RPN) Forth uses. The arithmetic expression is equal to 5 * (20 - 10) the result of which is pushed onto stack.

PS: One of the strengths of Forth is the ability to build a vocabulary (of words) around a particular problem in bottom-to-top fashion, much like Lisp. PPS: If you're ever interested to learn Forth, Starting Forth is a fantastic resource.

this post was submitted on 29 Dec 2024
33 points (92.3% liked)

Programming

17717 readers
187 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS