Email or username:

Password:

Forgot your password?
Devil Lu Linvega

Recently, I've been taken by this project of @wryl that might be of interest to folks diving into minimal virtual machines.

It's a string rewriting scheme with a single operator <>, similar to Thue, with the added capability of binding addresses in the input string to registers and manipulate them during the transcription.

It's an extremely elegant runtime, capable of emulating lisps, type systems, concatenative languages, all without any form of garage collection.

wiki.xxiivv.com/site/modal

25 comments
the bouncing paw 🎃

@neauoire @wryl reminds heavily of Markov algorithms I learned at uni. It was fun coming up with the rewriting rules! And more rewarding than those Turing machines 😤

Jorge Acereda

@neauoire @wryl Very intrigued by the possibilites... It should be possible to turn this into an efficient compiler by "simply" writing some rules to emit, say, C code, right?

(wryl)

@jacereda @neauoire Correct. In the past, I've used Modal to generate boilerplate and bytecode. As a general rewriting system, it's quite useful as a compiler.

kr1sp1n

@neauoire How do you run the lisp.modal example from your code repo? Where is 'define' defined? Or is this an old syntax, only running with the python implementation from @wryl ?

(wryl)

@kr1sp1n @neauoire The C implementation should be able to be invoked by running..

./bin/modal lisp.modal

.. from the top level directory after running `make`.

The old `define` syntax is replaced with `<>` in the C implementation. You can add..

`define <> define`

.. to the top of any Modal source file to run it with the Python implementation. Bear in mind, I/O won't work in the Python implementation.

Jorge Acereda

@wryl @kr1sp1n @neauoire In this case, to run lisp.modal I think you want the reverse:

<> define <>

kr1sp1n

@jacereda @wryl @neauoire
Thanks! Works with `<> define <>` at the top of examples/lisp.modal

Jorge Acereda

@neauoire @wryl I guess you're aware of XL, the language behind tao3d.sourceforge.net/

If so, could you comment on the differences for those that, like me, aren't familiar with rewriting languages?

Kartik Agaram

@neauoire @wryl Bug report for the ANSI C implementation:

$ cat x.modal
<> (?x dup) (?x ?x)
<> (?x ?y swap) (?y ?x)
<> ( ?x pop) ()

.. (1 2 3) (4 5 6) swap pop dup

$ gcc -g modal.c -o modal && ./modal x.modal
01 .. (4 5 6) (1 2 3) pop dup

02 .. (4 5 6) dup

00 .. (4 5 6)

<> (?x dup) (?x ?x)
<> (?x ?y swap) (?y ?x)
<> (?x pop) ()

(wryl)

@akkartik @neauoire Is this with the latest commit? We were just working through parsing this morning.

Devil Lu Linvega

@akkartik @wryl OOoh, haha my fix for the spacing issue broke it.. Thanks for the report Kartik, I'll fix this right away/

Devil Lu Linvega

@akkartik @wryl fixed :) we recently changed how whitespace is handled and it broke the pop rule.

Kartik Agaram

@neauoire @wryl For my part I have now found the repo ^_^ Was copying from the webpage earlier.

Devil Lu Linvega

@akkartik @wryl Let us know what you find while exploring Modal, we're still figuring stuff out, what's possible and whatnot.

I haven't documented the explode register(?*), but it's going to be really useful to do arithmetic.

<> (explode ?*) (str (?*))

.. (explode hello)
00 (str (h (e (l (l (o))))))

Go Up