开发者

Automatically Reload a File in LISP When a Command Is Entered

开发者 https://www.devze.com 2023-04-04 22:36 出处:网络
I\'m learning LISP for a class. I have a basic workflow setup in Ubuntu with my LISP file in VIM and an interactive LISP prompt in a terminal that I\'m using to test code as I write it. Is there a way

I'm learning LISP for a class. I have a basic workflow setup in Ubuntu with my LISP file in VIM and an interactive LISP prompt in a terminal that I'm using to test code as I write it. Is there a way to get LISP to load a specific file every time I type a command? It's getting a bit tiring having to constantly input (lo开发者_StackOverflowad 'initial-code.cl) (yes, even when I am using the terminal's history).


Can always try:

(let (fn)
  (defun l (&optional filename)
    (if filename
      (setf fn filename))
    (load fn)))

Works like this:

[2]> (l "x.lisp")
;; Loading file x.lisp ...
;; Loaded file x.lisp
T
[3]> (l)
;; Loading file x.lisp ...
;; Loaded file x.lisp
T
[4]> 

Pretty simple.

You can also do something like:

(defun go ()
  (load "project.lisp")
  (yourfunc 'your 'parameters))

Then you just type (go) and it reloads your file and calls your main entry point.

Or even combine them:

(defun gogo (&rest args)
    (l) ;; call (l "file.lisp") first to initialize it
    (apply #'yourfunc args))

then you can change your parameters easily

(gogo 1 2)
(gogo 2 4)

Ya know, it's lisp. Don't like something, change it.

With more time, you can write a simple wrapper that can build these on the fly. But you get the idea.


Most Lisp programmers would encourage you to use SLIME.

If you like Eclipse, there is also a Lisp plugin.

I know this doesn't really answer your question, but at least you can be aware of some alternatives.


You can try slimv, it is like slime for vim.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号