Ann: Mini Scheme (new version)

107 views
Skip to first unread message

Nils M Holm

unread,
Sep 15, 2009, 11:12:20 AM9/15/09
to

In the past days I have hacked Atsushi Moriwaki and Akira KIDA's
MiniScheme a bit and I must say that it is quite a nice and clean
implementation.

I added string pool compaction to the garbage collector and
implemented dynamic strings, the char type, and some I/O
procedures.

Major things that are missing at the moment are I/O (modulo those
I/O procedures that do not require a port type) and the complete
numeric tower except for fixnums. I did add overflow checking to
fixnums and type checking to primitives in general, though.

The entire interpreter code is now in a single file that loads
its high-level part from itself. A DOS binary (compiled with an
old Turbo C compiler) has a size of about 55KB (it can be reduced
to about 25KB with EXE compression). Compiling it statically on
FreeBSD 7.1 (without and fancy optimizations) gives:

% ls -l miniscm
-rwxr-xr-x 1 nmh nmh 175832 Sep 15 17:00 miniscm
% size miniscm
text data bss dec hex filename
147791 13376 14456 175623 2ae07 miniscm
%

In case you want to give it a try: http://www.t3x.org/miniscm

--
Nils M Holm | n m h @ t 3 x . o r g | http://t3x.org/nmh/

Benjamin L. Russell

unread,
Sep 17, 2009, 1:02:30 AM9/17/09
to

Thank you for your contribution to the Scheme community.

Incidentally, you have included test.scm, a test suite for Scheme 9
from Empty Space (see
http://www.t3x.org/4154544943/scheme-9-from-empty-space.zip), an
"interpreter for a broad subset of R5RS Scheme" [1], in the
miniscm.tgz file downloadable from http://www.t3x.org/miniscm ; to
what extent is Mini Scheme compatible with Scheme 9?

Also, do you have any textbooks or tutorials covering Mini Scheme?

-- Benjamin L. Russell

[1] Holm, Nils. M. _Scheme 9 from Empty Space._ 2007. Raleigh, NC:
Lulu Press, 2007. 7.
<http://www.t3x.org/4154544943/scheme-9-from-empty-space.zip>.
--
Benjamin L. Russell / DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile: +011 81 80-3603-6725
"Furuike ya, kawazu tobikomu mizu no oto."
-- Matsuo Basho^

Nils M Holm

unread,
Sep 17, 2009, 2:47:29 AM9/17/09
to
Benjamin L. Russell <DekuDe...@yahoo.com> wrote:
> Incidentally, you have included test.scm, a test suite for Scheme 9
> from Empty Space (see
> http://www.t3x.org/4154544943/scheme-9-from-empty-space.zip), an
> "interpreter for a broad subset of R5RS Scheme" [1], in the
> miniscm.tgz file downloadable from http://www.t3x.org/miniscm ; to
> what extent is Mini Scheme compatible with Scheme 9?

The test suite included in the Mini Scheme archive is a subset of
the S9fES 9 test suite. Mini Scheme is widely compatible to Scheme 9,
because they are both (slightly extended) subsets of R4RS. They are
only incompatible where they extend R4RS. Mini Scheme is lacking most
add-ons that Scheme 9 provides. Also, Scheme 9 uses "define-macro"
while Mini Scheme uses its own oddball macro implementation. I
intended to change this, but it fell off the priority queue.

Finally, in Mini Scheme '() is #f and in S9 it is #t. Mini Scheme
has "call/cc", which S9 lacks intentionally.

> Also, do you have any textbooks or tutorials covering Mini Scheme?

A tutorial for hacking Mini Scheme is in the back of my head, but
will take some time to get out of there. Do not hold your breath.

leppie

unread,
Sep 17, 2009, 9:44:01 AM9/17/09
to
Tiny question, how do I exit the interpreter on windows?

I tried Ctrl-Z/F6, tried (exit), tried (quit), nothing!

Thanks

leppie

Nils M Holm

unread,
Sep 17, 2009, 10:04:00 AM9/17/09
to
leppie <xacc...@gmail.com> wrote:
> Tiny question, how do I exit the interpreter on windows?
>
> I tried Ctrl-Z/F6, tried (exit), tried (quit), nothing!

MINISCM.EXE is an ordinary DOS program that reads standard
input and writes standard output, so ^Z should work fine.
It does on PCDOS. Note that the program is really a DOS
program, not a Windows program. What about ^C?

leppie

unread,
Sep 17, 2009, 11:19:11 AM9/17/09
to
On Sep 17, 4:04 pm, Nils M Holm <news2...@t3x.org> wrote:

I tried both ^Z and ^C, neither works.

Will re-simulate it when I get home and explain better.

BTW it was compiled with MSVC.

Thanks

leppie

leppie

unread,
Sep 17, 2009, 12:14:42 PM9/17/09
to
Hi Nils

Here is a 'full' transcript.

C:\incoming\miniscm>cl miniscm.c && miniscm
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01
for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

miniscm.c
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

/out:miniscm.exe
miniscm.obj
Mini Scheme 2009-09-14
> 'hello
hello
> (exit)
error: eval: unbound symbol: exit

> ^Z

error: eval: unbound symbol:

> ^X^X
error: eval: unbound symbol: ↑↑

> error: interrupted
error: interrupted

> error: interrupted
error: interrupted

> ^Z

error: eval: unbound symbol:

>

I get 'error: interrupted' when I press Ctrl-C.

This is on Vista in a command prompt.

Any ideas?

Cheers

leppie

Nils M Holm

unread,
Sep 18, 2009, 1:37:11 AM9/18/09
to
leppie <xacc...@gmail.com> wrote:
> C:\incoming\miniscm>cl miniscm.c && miniscm

Ah, I thought you were using the executable from the home page.

> Mini Scheme 2009-09-14
> > 'hello
> hello
> > (exit)
> error: eval: unbound symbol: exit

This is as expected. Because ^D works fine on Unix and
~Z works fine on DOS, I thought there is no need for
such a procedure.

> > ^Z
>
> error: eval: unbound symbol:

This puzzles me indeed. Ah, wait, are you running
Cygwin or something like that? In this case ^D may
do the trick. (I am just guessing here, I have not
touched Windows in my entire life and do not know
really much about Cygwin, either).

> > error: interrupted
> error: interrupted

I forgot: miniscm is catching SIGINT and returns
to the REPL.

> Any ideas?

^Z in a DOS box and maybe ^D in CygWin should really
work. What happens when you run cat(1)? How do you send
it an EOF?

Reply all
Reply to author
Forward
0 new messages