Twenty-Seventh, the Language

I have had an irresistible idea lately. What if you had forth but you had 256 stacks. We can't start there, what if it was based on the venerable MUF(Multi user forth) language, which has some relatively simple typing and generally provides a higher level interface, ameliorating one of the biggest issues I personally have in learning the Forth language proper, the untagged nature of the memory space.

Of course, this comes at a performance decrease, 256 stacks is a lot of context to lug around, and every instruction needs to be able to fit N bytes for the addresses of the operands, which means that the decoding will be more complicated.

There are a couple of types that MUF implements, and so too shall this implement:

  • Integer
  • Floating point(double precision)
  • Strings
  • Dynamic growable arrays
  • Associative ordered dictionaries

Given that I'm not writing a MUCK, I don't need to worry about property or database manipulation directly, and the time-slicing is an entirely optional component rather than an essential way to partition a single core across a hundred processor hungry players.

MUF implements call by name, using a string addressed call. For the sake of consistency, and because I can't imagine how awful it would be to have to specify the entire list of argument stacks in a variable length instruction, the CALL instruction shall be expected to draw from stack 0. This instruction will not normally be invoked by the user, but it may if the user wants to permit a dynamic choice of what word is invoked.

As I am basing it off of MUF, so things like sockets, file handles, etc are understood to be integers.

The language design should permit an unhinged degree of indirection, deception, and flow while writing while permitting an unsettling mixture of register and stack based paradigms.

This is a project which I intend to use for an iRODS rule engine, but my intention is to make this flexible enough that you could, if you wanted, write an actual muck with it.

My current thought on how this should look for the primitive instructions is like this:

pop[0] (pops from the 0th stack)
123[1] (pushes 123 to the 1st stack)
swap[1][1] (swaps the top two items in stack 1)
swap[1][2] (swaps the top item from stack 1, and the top item from stack 2)
rot[1][1][1] (rotate the top 3 items of stack 1)
rot[1][1][2] (rotate the top 2 items of stack 1 and the top item of stack 2)
rot[1][2][1] (rotate the top item of stack 1, the top item of stack 2, and the second item of stack 1)
rot[1][2][3] (rotate the first item of stacks 1,2,and 3)
... etc

In either case, I'm quite excited, this should be a language that will allow all sorts of silly hacks.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.