Staapl: Forth on Scheme for embedded controllers

[As seen on comp.lang.scheme]

I think the rationale is that Forth comes on controllers, but you might want to do some metaprogramming, so put the 2 together.

[edit: fixed hyperlink]

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

On metaprogramming in Forth...

I've never met a Forth that DIDN'T let me meta-program. Maybe I'm totally missing something?

sufficiently large values of 'metaprogramming'?

ja, i know what you mean. i haven't used Staapl at all, so i can only infer/guess; i guess the authors have hit situations where Forth's abilities weren't enough or didn't quite fit as they liked?

unrolling Forth's reflection

Forth is very elegant minimalism, and hard to improve if you want a minimally complex self-hosted system.

But when you switch to a cross-compiled Forth system, the target side can be simplified a lot by taking out reflection. For interactive applications, Staapl uses Frank Sergeant's 3 instruction Forth.

On the host side however, minimalism isn't really necessary. Having "just Forth" on the host side really seems like a limitation. I see no reason why a cross compiler written in Forth can't be replaced by one written in Scheme. To make this easier, Staapl uses an impedance matching language Scat, which is a concatenative language based on Joy. Staapl's code transformers are modeled after Forth's immediate words, but are represented as pure Scat functions. All reflection is unrolled as acyclic PLT Scheme modules, making metaprogramming more straightforward.

When you skew ordinary Forth from words towards macros an approach like this where macros are as clean as possible seems to make sense. Staapl's PIC18 Forth starts out as all macros. There are no kernel words.

I've just updated the scribble docs in the PLaneT package. The main project site is at http://zwizwa.be/staapl.

Why do people try to improve on Forth?

Forth -- like Scheme -- is perfect just the way it is. Why do people try to "improve" on Forth?

Scheme is perfect?

I dunno, I can see many ways to improve the language, at least for some domains. I'd like a lazy Scheme, a typed Scheme, a more modular Scheme. or a Scheme that takes functional programming seriously.