sbcl

Reset state in Common Lisp

戏子无情 提交于 2019-12-03 01:17:26
Newbie Common Lisp question here. Is there a way to reset the state of the environment? What I mean, is there some command that brings the REPL back to the same state it was right after it started up, that is, uninterning all variables, functions, etc. Or if that's not in the Common Lisp standard, is there some extension in SBCL (the implementation I use) to do that? ( EDIT : I know that in SLIME, M-x slime-restart-inferior-lisp does that but I wonder if there's a way without restarting the process) Not in general, no. I occasionally want to do something like that, so my workflow is generally

(Emacs) Text is read only?

隐身守侯 提交于 2019-12-02 23:25:05
So I was working in emacs and the suddenly, the slime-repl sbcl says text is read only. Well that's great because now I can't type anything into it. How do I fix? devon "Buffer is read-only" can be cured by C-x C-q but as Drew & phils said, "Text is read-only" is very different -- it means some part of the buffer has a read-only property. Try moving away from the read-only part, e.g., to the end of the buffer. Emacs Lisp Manual > elisp.info > Text > Text Properties > Special Properties Since changing properties counts as modifying the buffer, it is not possible to remove a `read-only' property

How to use quicklisp when CL program is invoked as a shell script?

放肆的年华 提交于 2019-12-02 22:56:25
I am currently have a small program in Common Lisp, which I want to run as a shell script. I am using the SBCL and perfectly fine with this so will prefer to stay on this platform. :) I am aware about the --script option and it works flawlessly except for (ql:quickload) form. My program uses the CL-FAD , which loads through ql:quickload (I think I should mention that it is package-loading function from quicklisp ). When script runs up to evaluating the (ql:quickload :cl-fad) form, it breaks with the next error: package "QL" not found Program is packed in the single source file, which has

A simple example of using the stepper in SBCL

扶醉桌前 提交于 2019-12-02 20:47:41
Going through the computation with the LispWorks stepper is rather intuitive, but I cant figure it out in SBCL. Can somebody please give me a step-by-step example of how to use the SBCL stepper in the REPL on some simple function? Thanks. * (proclaim '(optimize (debug 3))) * (defun foo (a b) (* (+ a b) b)) FOO * (step (foo 1 2)) ; Evaluating call: ; (FOO 1 2) ; With arguments: ; 1 ; 2 1] step ; Evaluating call: ; (+ A B) ; With unknown arguments 0] step ; Evaluating call: ; (* (+ A B) B) ; With unknown arguments 0] step ; (FOO 1 2) => 6 Commands: Stepping: START Selects the CONTINUE restart if

How can I run SBCL code under a Unix-like operating system in a convenient way?

给你一囗甜甜゛ 提交于 2019-12-02 20:29:18
(David James both wrote the question and an answer. I'll edit it to conform to Stackoverflow standards.) Using SBCL you can compile Lisp code to machine code. Like Java, .net, C++ and even C you will need the runtime. So there are two ways to compile Common Lisp code. First is to make huge binaries which is explained in SBCL documentation. No SBCL needed on target machine. The other way is a more flexible one, which is to create machine code in a fasl (FASt Load) format. The SBCL runtime is needed on the target machine. How does the second way work under a Unix-like operating system? Rainer

Compiling Common Lisp to an executable

感情迁移 提交于 2019-12-02 15:11:10
I recently started learning Common Lisp using SBCL. How can I compile my Lisp programs into a Windows binary? Making hello.exe: * (defun main () (print "hello")) MAIN * (sb-ext:save-lisp-and-die "hello.exe" :toplevel #'main :executable t) [undoing binding stack and other enclosing state... done] [saving current Lisp image into hello.exe: writing 3160 bytes from the read-only space at 0x22000000 writing 2592 bytes from the static space at 0x22100000 writing 30134272 bytes from the dynamic space at 0x22300000 done] > dir hello.exe 31,457,304 hello.exe > hello.exe "hello" 31 MB executable file!

Lisp SYMBOL-PACKAGE-LOCKED-ERROR

非 Y 不嫁゛ 提交于 2019-12-02 07:28:40
I'm new to Lisp so when I wrote the function in SBCL (defun subst (new old l) (cond ((null l) '()) ((eq old (car l)) (cons new (cdr l))) ((cons (car l) (subst new old (cdr l)))))) it gives error SYMBOL-PACKAGE-LOCKED-ERROR,a Style-Warning and a Warning, please help to resolve it You're trying to redefine cl:subst . According to §11.1.2.1.2 of the HyperSpec, it's undefined what happens when you try to do that. Most implementations have some sort of package lock which prevents such redefinitions. You can get around those, by unlocking the package, but it would be better in this case to either

Push doesn't modify the list being a function argument

独自空忆成欢 提交于 2019-12-02 04:46:18
问题 I'm new to common lisp, so hope someone would clarify this to me: say we have a list and want to add an item with push to modify it: CL-USER> (defparameter xx '(1 2 3)) XX CL-USER> xx (1 2 3) CL-USER> (push 100 xx) (100 1 2 3) CL-USER> xx (100 1 2 3) as expected. But when i try to do the same with the function, it doesn't modify a list: CL-USER> (defun push-200 (my-list) (push 200 my-list)) PUSH-200 CL-USER> (push-200 xx) (200 100 1 2 3) CL-USER> xx (100 1 2 3) so i tried to compare argument

Push doesn't modify the list being a function argument

无人久伴 提交于 2019-12-02 01:21:53
I'm new to common lisp, so hope someone would clarify this to me: say we have a list and want to add an item with push to modify it: CL-USER> (defparameter xx '(1 2 3)) XX CL-USER> xx (1 2 3) CL-USER> (push 100 xx) (100 1 2 3) CL-USER> xx (100 1 2 3) as expected. But when i try to do the same with the function, it doesn't modify a list: CL-USER> (defun push-200 (my-list) (push 200 my-list)) PUSH-200 CL-USER> (push-200 xx) (200 100 1 2 3) CL-USER> xx (100 1 2 3) so i tried to compare argument and my list like this: CL-USER> (defun push-200 (my-list) (format t "~a" (eq my-list xx)) (push 200 my

How to handle accents in Common Lisp (SBCL)?

爱⌒轻易说出口 提交于 2019-12-01 21:46:37
That's probably very basic, but I didn't know where else to ask. I'm trying to process some text information in an SLIME REPL from a file that are written in Portuguese, hence uses lots of accents characters - such as é, á, ô, etc.. When I'm handling texts in English I use the following function: (defun txt2list (name) (with-open-file (in name) (let ((res)) (do ((line (read-line in nil nil) (read-line in nil nil))) ((null line) (reverse res)) (push line res)) res))) that cannot read accented characters, giving the error "the octet sequence #(195) cannot be decoded.". So my question is: Is