[plt-scheme] MzScheme: extending vs. embedding to build a text editor

From: Peter Michaux (petermichaux at gmail.com)
Date: Sun Jul 13 19:57:12 EDT 2008

Hi,

Suppose I wanted to build a text editor like emacs where the use is
able to extend the editor using MzScheme (rather than emacs-lisp.) It
seems there are two main ways this could be done.

-----

First, I could write MzScheme extensions [1] for ncurses. The editor
could then be written in Scheme from start to end whatever that means.
It would certainly be a Scheme-centric implementation. I could then
edit a file with the command

  mzscheme myeditor.ss some-file-to-edit.txt

(The whole program with could be compiled to a native binary somehow?)

-----

Second, the opposite way would be to write a very small C application
and embed MzScheme [2] into that application. I could expose the
ncurses API by creating and adding ncurses procedures to the embedded
Scheme environment. The C could then load some "myeditor.ss" file into
the Scheme environment and the majority of the editor program could be
defined in Scheme. Since I would be compiling a C program the editor
could be started with

  myeditor some-file-to-edit.txt

-----

I've toyed with some other extensible/embeddable languages and the
same problem arises. I'm not sure which way around would be the right
way to go. I'm interested in what others would do or if there is an
obvious definite answer I don't know because I am new to MzScheme.

Thank you,
Peter

[1] http://docs.plt-scheme.org/inside/overview.html#(part._.Writing_.Mz.Scheme_.Extensions)
[2] http://docs.plt-scheme.org/inside/overview.html#(part._embedding)


Posted on the users mailing list.