Version 1 of A Joy implementation in Tcl

Updated 2004-02-11 08:28:47

SS 2004-02-10: I used the last weekend to implement Joy in Tcl. It's not very fast of course, and still not complete, but does tail call optimization, has first class continuations, and is stackless (The interpreter never call itself), so it's simple to transfer an entire running program from an interpreter to another one.

Changelog

 2004-02-11 Now the implementation is a superset of Joy, that I called 'Apathy'. It's basically Joy with locals designed
            to don't break the Joy semantics. Now Joy primitives are implemented in Apathy and there are more primitives.

Too big to put it here on the Wiki, so download it from http://www.hping.org/tclsbignum/joy.tcl if you are interested.

Run it with

  tclsh joy.tcl

to use the interactive mode, or pass an file name to execute a program written in Joy.

As stated, it's still not finished. Many primitives are missing, but can easily implemented in Joy itself. Also note that currently the 'set' data type is missing.

Btw it is able to run this (From the Joy tutorial):

 DEFINE permlist ==
       [ small ]
       [ unitlist ]
       [ uncons ]
       [ swap 
         [ swons
           [ small ]
           [ unitlist ]
           [ dup unswons [uncons] dip swons ]
           [ swap [swons] cons map cons ]
           linrec ]
         cons map
         [null] [] [uncons] [concat] linrec ]
       linrec.

 [1 2 3 4 5] permlist

Use the help command to print a list of the defined words.

I plan to have a fully compatible interpreter in some day.