[slim-vim] Blue sky, shoot the moon: compile Vim-script to Lisp and thence to C

Larry Clapp larry at theclapp.org
Thu May 25 19:27:17 CDT 2006


On Thu, May 25, 2006 at 03:25:54PM -0700, Brad Beveridge wrote:
> On 5/25/06, Larry Clapp <larry at theclapp.org> wrote:
> > So I'm working on the Lisp->Vim FFI, and wondering if I can
> > eventually work it out so that
> >
> >   (vim:append 12345 "some-string")
> >
> > calls Vim's internal f_append() function directly (instead of
> > building a string that says "append( 12345, \"some-string\" )" and
> > calling "exec" on it, which Vim then has to parse, look up
> > "append" in its table (binary search -- fast, but slower than a
> > pointer-indirection), and THEN call f_append()).
> My turn to nitpick :)  Wouldn't that be ml_append()?  f_append is
> the function that Vim script calls, which in turn calls ml_append.

*laugh*  Hey, man, when I publish some actual code, then you can
nitpick that.  :)

Nevertheless, in my defense, from the two or three painstaking seconds
of research that I did for that email, it appeared that f_append did
some bookkeeping aside from ml_append that I didn't want to just
discount.

> > I don't know yet :) , but it occurred to me that if I can, and if
> > I can compile it (and why wouldn't I?), then we'll be C "all the
> > way down".  And then, perhaps, we can really make a name for
> > ourselves by writing a Vim-script -> Lisp -> native code compiler.
> 
> That sounds very cool, having Vim controllable from Lisp in a
> somewhat complete fashion would be extremely useful IMHO.

Yeah, but tough, since Vim's main loop is non-reentrant.

> So you are proposing having the Vim deep internals exposed to Lisp.

No, I was just proposing removing the interpretive layer between Lisp
and the C functions called by Vim scripts, as a performance
enhancement.

Now, I wouldn't *object* to having the deep internals exposed, but I
don't know that it'd gain us all that much.  If we want an editor
completely written in Lisp, we know where to find it.  :)

> It appears to me there are two really nice things about ECL that
> will help here
> 1) The ECL compiler transates Lisp -> C
> 2) ECL lets you embed C code in Lisp.
> 
> I'm thinking it is possible to write the FFI in Lisp and call the
> Vim internals directly.  During a build of Vim you would first
> process the Lisp code to get C, then compile the resulting file into
> Vim.  The embedded ECL interpreter can then call the Lisp FFI.  Is
> this what you're planning on doing?

Well, I haven't *planned* *anything* yet, but if I do, I'll start
there, yeah.  For the moment, I just build strings and get Vim to eval
them.

-- Larry



More information about the slim-vim mailing list