Emacs in Scheme! 
Author Message
 Emacs in Scheme!

Emacs and Elisp have three very useful properties:

        1. They are well known, and well documented.
        2. Elisp's abstractions work on both on graphics and ascii terminals.
        3. There is a large library of useful elisp code.

This makes me doubt that it is a good idea to glom a Scheme compiler
onto Emacs with hopes of converting existing packages to Scheme.  I
think it would be a clever hack -- i'm just not sure it would be all
that useful.  After all, there is a lot of elisp to convert if you
want to convert elisp to scheme; it will be tedious to make the new
Scheme-based abstractions work as well as elisp on both graphics and
ascii terminals; and it would be a lot of work to educate the world
about the new system, not to mention a waste of a lot of established
state.

I like Scheme too, so I have an alternative suggestion: embeddable
Emacs in Scheme!  Such a system would have two parts:

        1. An full implementation of elisp in Scheme.

        2. Abstractactions around the elisp interpreter to give emacs
           an `outside' that is accessible from Scheme.

When I say ``give emacs an `outside','' I mean something like this:
Imagine a scheme data structure type called EMACS-SESSION.  An
EMACS-SESSION would have several component parts: a collection of
buffers, a set of redisplay hooks, and controls for an instance of an
elisp interpreter.  It would be possible to examine and modify buffers
and elisp environments from the Scheme side.  There is really no need
to expose the Scheme side to the elisp side.

It should be possible to instantiate more than one EMACS-SESSION
object at a time.  In addition, it should be possible to move buffers
between sessions.  These features will allow one to get the benefits
of a multi-threaded Emacs -- when a slow command is executing, the
emacs-session can `fork' into one busy and one responsive session.
After the slow command is done, the two sessions can `join' back into
one.

I can see a few strategies for implementing elisp in Scheme.  The
Right Thing might even be a combination of these strategies:

        - source to source translation
                This has been tried before, but i don't know the reference.
                My recollection is that not all code could be successfully
                converted -- but the goal (as i recall) was to convert
                elisp to edwin scheme, rather than to implement
                elisp semantics faithfully.  Just reimplementing elisp
                might be simpler.

        - reimplement the elisp bytecode machine
                This would probably be too slow.

        - choose a VM based Scheme, and write an elisp front end for it
                My personal favorite.  It may also be possible
                to code an elisp VM in Scheme without giving up
                too much performance.  If nothing else, that would
                be a good way to prototype the VM.

Component parts for a buffer data structure, keymaps, event loops
etc. can be found in Edwin or in some code that I have.

I think an implementation of EMACS-SESSION would be an excellent
addition to Scheme based user interface toolkits like Stk (or the one
i'm writing ;-).  It might also be nice for people who use Scheme on
systems that don't conveniently run Emacs at the same time.

On the off chance that somebody is interested in trying to do this,
please send me some email.

-t



Thu, 27 Feb 1997 13:01:25 GMT  
 Emacs in Scheme!
Perhaps there is an alternative approach. It might be possible to make
scheme and elisp coexist, thus providing the better of both worlds.

I would imagine a mix-scoped lisp engine ala Common Lisp. I am not a
big expert on Common Lisp, but as I understand it, the `defvar'
construct (and friends of course) introduce a special variable, which
is a variable of dynamic scope, while all variables introduced by
`let' (and friends) are statically scoped.

So all elisp programs, with properly declared variables, would
continue to run, on the assumption that one only relies on dynamic
scope for interfunction features, where you really should have
declared the variables that are used. A scheme environment could be
set up by redefining functions such as defvar in the proper way.

Some major hacking is needed on the emacs lisp engine, but perhaps
some performance gains could achieved along the way.

Of course one has to start by determining what is the ultimate goal:
is it scheme compability or speed or whatever.

------------------------------------------------------------------------------
Christian Lynbech               | Hit the philistines three times over the
office: R0.33 (phone: 3217)     | head with the Elisp reference manual.

------------------------------------------------------------------------------



Fri, 28 Feb 1997 16:56:33 GMT  
 Emacs in Scheme!
Quote:
Tom Lord writes:

 > This makes me doubt that it is a good idea to glom a Scheme compiler
 > onto Emacs with hopes of converting existing packages to Scheme.

It's quite unrealistic. My reason to look into this was two fold:

  1) To get a scheme coexisting with emacs in less space (memory).
  2) To have to possibility of writing emacs code in scheme.

I'm confident that with _some_ extensions to the Emacs VM machine
it's possible to make something close to R4RS Scheme coexist with
Elisp, but it would need the help of an emacs expert.

                                    it will be tedious to make the new
 > Scheme-based abstractions work as well as elisp on both graphics and
 > ascii terminals;

?? Why? I run Scheme on ascii terminals just fine. I even run Scheme
on underpower machines (= 4Mb) sans probleme.

                    and it would be a lot of work to educate the world
 > about the new system, not to mention a waste of a lot of established
 > state.

It shouldn't be a problem to allow two views on the world.

 > I like Scheme too, so I have an alternative suggestion: embeddable
 > Emacs in Scheme!  Such a system would have two parts:

This is of course the "right way", but it requires much more work.

 >      - reimplement the elisp bytecode machine [in scheme]
 >              This would probably be too slow.

Not if the scheme had a resonably good native code compiler.

All this sounds very much like edwin. Wouldn't edwin be a natural
place to start? Has anyone ever tried to implement the Emacs VM
in edwin?

Regards,
--

Aarhus University, Ny Munkegade 116        Phone: +45 89423217
DK-8000 Aarhus C, Denmark.                 Fax:   +45 89423255
<A HREF="http://ftp.daimi.aau.dk/~tthorn">Web</A>



Sat, 01 Mar 1997 03:28:03 GMT  
 Emacs in Scheme!


                                       it will be tedious to make the new
    > Scheme-based abstractions work as well as elisp on both graphics and
    > ascii terminals;

   ?? Why? I run Scheme on ascii terminals just fine. I even run Scheme
   on underpower machines (= 4Mb) sans probleme.

Some context was lost.  I meant that it would be tedious to define
a library of Scheme functions that, like Emacs, obscured whether the
system was running on an ascii or a graphics terminal.  The decision
to support both kinds of display permeates the design of Emacs.  There
is no reason why similar design decisions can't be made for a Scheme
based system -- the point was simply that it would take a lot of work
just to catch up to Emacs.

                       and it would be a lot of work to educate the world
    > about the new system, not to mention a waste of a lot of established
    > state.

   It shouldn't be a problem to allow two views on the world.

I agree, hence my suggestion:

    > I like Scheme too, so I have an alternative suggestion: embeddable
    > Emacs in Scheme!  Such a system would have two parts:

   This is of course the "right way", but it requires much more work.

I disagree that this approach require more work.  The hidden cost of
Scheme-in-Emacs is the work it would take to make the Scheme
implementation practical for non-trivial programs.  Most of the data
structures for Emacs-in-Scheme already exist, so that route isn't
as expensive as it might look at first.

    >           - reimplement the elisp bytecode machine [in scheme]
    >                   This would probably be too slow.

   Not if the scheme had a resonably good native code compiler.

   All this sounds very much like edwin. Wouldn't edwin be a natural
   place to start? Has anyone ever tried to implement the Emacs VM
   in edwin?

I believe that someone at MIT wrote a translator that was good enough to
convert dired.el to Edwin Scheme.  I'll bet i saw this either thomping
around on altdorf or in the Scheme repository at indiana, but i really don't
recall for sure.

-t



Sun, 02 Mar 1997 10:25:49 GMT  
 Emacs in Scheme!

Quote:

> Tom Lord writes:

[...stuf...]

Quote:
>> it will be tedious to make the new Scheme-based abstractions work
>> as well as elisp on both graphics and ascii terminals;

Tommy> ?? Why? I run Scheme on ascii terminals just fine. I even run
Tommy> Scheme on underpower machines (= 4Mb) sans probleme.

I too have run scheme without problems on ascii terminals, but isn't
the graphics part lacking? As I understand it, scheme lacks an agreed upon
graphics extension ala CLX (or at higher levels). I seem to remember
that work has been done both for tk and xlib, but have this been
adopted by a larger audience?

Emacs can in fact be seen as much as an application environment as an
editor, and in that you have access to quite some X functionality, and
in forms you can use. It is not just raw Xlib hacking. I do not say it
is perfect in any sense, but it certainly is there.

[...stuff...]

Quote:
>> I like Scheme too, so I have an alternative suggestion: embeddable
>> Emacs in Scheme!  Such a system would have two parts:

Tommy> This is of course the "right way", but it requires much more
Tommy> work.

Not necessarily - it depends on your preferences. My chief concern is
compability, and reimplementing emacs in scheme is branching off
the GNU Emacs line. Much better, in my view, to hack emacs itself and
persuade RMS that it is an improvement. That should not be a problem :-).

------------------------------------------------------------------------------
Christian Lynbech               | Hit the philistines three times over the
office: R0.33 (phone: 3217)     | head with the Elisp reference manual.

------------------------------------------------------------------------------



Sun, 02 Mar 1997 14:47:09 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. emacs and scheme to c

2. Emacs and Scheme

3. emacs and Scheme

4. emacs and scheme

5. emacs and scheme under win95

6. Win-Emacs and MIT Scheme

7. Problem: MIT Scheme 7.4.2 on Windows NT 4.0 under NT Emacs

8. Scheme and Emacs

9. Hacking scheme-mode in emacs?

10. MIT Scheme under Emacs 19 problem

11. emacs interface to scheme

12. c-scheme on Linux using emacs

 

 
Powered by phpBB® Forum Software