TinyScheme Package Library

I’m still working to improve the TinyScheme package. I figured out the configuration and patches I needed to build the TinyScheme libraries, represented in this commit:

commit 797b5408dc

This patch causes libtinyscheme.so and libtinyscheme.a to be built in the build_dir directory in the libreCMC source code, but it does not actually get them included in the ipkg package. I was planning to add that in as a selectable package option.

The library is for embedding TinyScheme in another program.

TinyScheme Package in libreCMC

My TinyScheme package was accepted into libreCMC, commit 4a64056e70. Until their next build (a few months away) I’ll keep a binary package available for mips_24kc. That installs on the TPE-R1100, GL-AR150, GL-AR300M16, and GL-AR300M targets, among others.

root@pathos:~# tinyscheme 
TinyScheme 1.41
(define (fact n) 
   (do ((rem n (- rem 1))
        (acc 1 (* rem acc)))
   ((= rem 1) acc)))
ts> fact
(fact 4)
ts> 24
(map fact '(1 2 3 4 5 6 7 8 9 10 11 12 13))
ts> (1 2 6 24 120 720 5040 40320 362880 3628800 39916800 479001600 1932053504)

The 32 bit integer overflow is visible at (fact 13).

TinyScheme Package

Since discovering libreCMC, I was discouraged by the lack of a lisp package. I was able today to hack together a TinyScheme Makefile for OpenWRT / libreCMC, and was able to build a mips_24kc package, which installs at least on my GL-AR300M units. It should install just as well on the GL-AR150 and the TPE-R1100.

EDIT: Package moved. See the more recent post.

This package, however, only installs TinyScheme itself, plus the init.scm file. There is also a shared library for embedding TinyScheme in another application, but I had trouble getting that to build. But at least we have our interpreter:

root@pathos:~# tinyscheme 
TinyScheme 1.41
(+ 2 3 4)
ts> 9
(write "Hello World!")
ts> "Hello World!"#t
(define (fact n) (if (= n 1) 1 (* n (fact (- n 1)))))
ts> fact
(fact 4)
ts> 24

Scripts files can be used:

root@pathos:~# cat script.scm
#!/usr/bin/tinyscheme -1

   "2 + 2 = "
   (number->string (+ 2 2))

root@pathos:~# ./script.scm
2 + 2 = 4