As I use stumpwm (a common-lisp window manager), I normally always have a lisp process running. So I was wandering if there is a way I can use that instance to evaluate "scripts"?
What I want to do is to write small lisp scripts and instead of executing them in their own separate instaces, I want to send them to an already running SBCL.
For example, I could try connecting via swank, but I don't know how to stablish a connection without slime.
Is there some way to do this?
Thanks!
Use running lisp as script interpreter
Re: Use running lisp as script interpreter
If I'm understanding correctly, you should try it this way...beren wrote:As I use stumpwm (a common-lisp window manager), I normally always have a lisp process running. So I was wandering if there is a way I can use that instance to evaluate "scripts"?
What I want to do is to write small lisp scripts and instead of executing them in their own separate instaces, I want to send them to an already running SBCL.
In your .stumpwmrc:
Code: Select all
(load "/path/to/my/script.lisp")
Code: Select all
(defun my-scripty-func ()
...)
Code: Select all
(defcommand do-scripty-thing () () (my-scripty-func))
(define-key *root-map* (kbd "C-M-Z") "do-scripty-thing")
"If you want to improve, be content to be thought foolish and stupid." -Epictetus
Re: Use running lisp as script interpreter
Thanks Duke,
Although something like that would work, I was thinking in something more generic. Just executing my lisp scripts in a terminal as ./script.lisp.
where script.lisp would be something like
and lispconnect would be in charge of connecting to a running lisp or spawning a new one, and send the rest of the script. That way there is no need to start a new process each time, and the state of the machine is persistent.
Although something like that would work, I was thinking in something more generic. Just executing my lisp scripts in a terminal as ./script.lisp.
where script.lisp would be something like
Code: Select all
#!/usr/bin/env lispconnect
(defun ...()...)
-
- Posts: 406
- Joined: Sat Mar 07, 2009 6:17 pm
- Location: Brazil
- Contact:
Re: Use running lisp as script interpreter
I would create a thread in your "server" that is responsible for listening to a socket. Whenever something is received from that socket, it interprets that as a string that contains code. Then I would write a small C or Lisp program that sent this code through that socket.
One nice alternative would be to use DBus to send messages. There is an attempt of a DBus client here, unfortunately I think it can't even send or receive complete messages yet.
One nice alternative would be to use DBus to send messages. There is an attempt of a DBus client here, unfortunately I think it can't even send or receive complete messages yet.
Re: Use running lisp as script interpreter
I think sockets are a good alternative. Althought they seem quite implementation dependent.
I'll try to code something simple, and if I succed I'll post it here. Of course if anyone else already have something like this feel free to post
I'll try to code something simple, and if I succed I'll post it here. Of course if anyone else already have something like this feel free to post
