Home > database >  How to require .el file when working with common lisp?
How to require .el file when working with common lisp?

Time:01-21

An additional library mylibrary.el for emacs (v 26.3) was added to load-path and is autoloaded in my init.el file.

The library is also listed under my installed packages in emacs (M-x list-packages) and is provided through (provide 'mylibrary) in mylibrary.el.

The file can be executed in emacs with M-x mylibrary but cannot be required in my slime-repl session.

CL-USER> (require 'mylibrary)
; Evaluation aborted on #<SB-INT:EXTENSION-FAILURE
 "Don't know how to ~S ~A." {1007A5F073}>.

CL-USER> (require 'asdf)
NIL

any ideas why I can require asdf and not my library?

CodePudding user response:

When running Slime to execute Lisp code from Emacs, there are two separate interpreters: the one in Emacs that interprets Emacs Lisp (Elisp), and the one in your Common Lisp (CL) implementation that is executed in a separate process: Slime is written in Emacs Lisp and connects to a server called Swank, implemented in Common Lisp.

Emacs Lisp shares a lot of similarities with Common Lisp, but is a different language. It would be surprising if a library written in Elisp could be interpreted without modification in CL.

You can require asdf because it is written in CL and available as a built-in in most implementations.

Note that from the Lisp side of things, you can call (swank:eval-in-emacs emacs-expr) to ask Emacs to run some Emacs Lisp code for you (provided you turn the security flag to false in Emacs). I use this to visit some files from the Lisp process but this is not necessarily what you need here (depending on what your library does, it might be possible to find an equivalent one in CL).

CodePudding user response:

Usually, Common Lisp code has the file ending .lisp.

Emacs Lisp code has the file extension .el.

Racket (originally Scheme) code has the file extension .rkt.

Scheme code has the file extension .scm.

Clojure code has the file extension .clj.

ClojureScript code has the file extension .cljs.

(There are some more Lisps but these are the main ones).

These are different languages / lisp dialects, though they are all from the Lisp language family.

They need different compilers and interpreters. Therefore, you can't cross-exchange codes from one lisp dialects to the other. Although, if you know the dialects it might not be too difficult for you to translate them into the other language.

And sometimes (Common Lisp and Scheme) they have even different implementations with slight implementation-specific differences. Common Lisp:

  • SBCL
  • ABCL
  • CLISP
  • ECL
  • Franz Lisp
  • CMUCL ...

Scheme:

  • MIT/GNU Scheme
  • Chez Scheme
  • Chicken
  • GNU Guile
  • Gauche ...

implementations with varying implementation details.

Only with Clojure, ClojureScript and Rackt you can be sure that they have just one main/official implementation.

  • Related