Skip to content

wi11dey/Schemel

Repository files navigation

Schem.el

Ein Schemel (über althochdeutsch [fuoʒ]scamil aus spätlateinisch scamillus „Bänkchen“ zu lateinisch scamnum „Bank“) oder Hocker ist ein einfaches Sitzmöbel ohne Lehne. Durch das Fehlen von Arm- und Rückenlehne unterscheidet sich der Schemel von einem Stuhl.

https://de.wikipedia.org/wiki/Schemel

Schem.el is a a stepping-stool allowing Emacs to run and Edebug R5,6,7RS Scheme natively. Interop between Elisp and Scheme is seamless: you can even write Emacs customizations and interactive commands in Scheme.

How it works

Schem.el is a nanopass [cite:Keep and Dybvig] transpiler from R5,7RS Schme to Elisp, together with psyntax [cite:Ghuloum and Dybvig]. The transpiler is then bootstrapped by transpiling itself to Elisp, using Guile as the primordial R6RS Scheme implementation, after which Emacs can transpile (and optionally, byte- and native-compile) all Scheme.

The bootstrap proceeds by the following Tombstone diagram:

./bootstrap.svg

call/cc is fully supported, as all Scheme code first transformed to CPS. Tail-call optimization and first-class continuations are implemented by each Schemel procedure returning values and the next continuation, which is executed iteratively by the Schemel Elisp runtime using only a constant amount of stack space. This makes Schemel strictly more powerful than Elisp itself.

schem.el consists of the Schemel Elisp runtime, while schemel.scm.el is the transpiled transpiler, used by the runtime for Scheme eval.

References

  1. Keep, Andrew W., and R. Kent Dybvig. “A nanopass framework for commercial compiler development.” Proceedings of the 18th ACM SIGPLAN international conference on Functional programming. 2013.
  2. Abdulaziz Ghuloum and R. Kent Dybvig. Portable syntax-case URL http://www.cs.indiana.edu/chezscheme/syntax-case/