sbcl

example of using external libraries or packages in Common Lisp

喜欢而已 提交于 2021-02-18 16:54:49
问题 In Common Lisp, quicklisp is a popular library management tool. I'm going to use that tool and I'm going to try and use CL-WHO. I use the SBCL 1.0.57 implementation. I'm going to answer my own question below. As a beginner, it's not clear how ASDF and quicklisp actually work together. And so it's not clear how to actually use packages or libraries that you've downloaded through quicklisp in an external source file. The quicklisp FAQ, at least at this moment, does not help. In python, it's

How to convince Lisp SBCL to do inline fixnum arithmetic?

為{幸葍}努か 提交于 2021-02-08 05:02:03
问题 I've found some techniques in other SO answers, but apparently I've been unable to convince SBCL to do inline fixnum arithmetic: (declaim (optimize (speed 2) (safety 1))) (declaim (ftype (function (fixnum fixnum) double-float) fixnumtest) (inline fixnumtest)) (defun fixnumtest (i j) (declare (type fixnum i j)) (let* ((n (the fixnum (+ i j))) (n+1 (the fixnum (1+ n)))) (declare (type fixnum n n+1)) (/ 1.0d0 (the fixnum (* n n+1)) ) ) ) (defun main () (format t "~11,9F~%" (fixnumtest 2 3)) )

How to convince Lisp SBCL to do inline fixnum arithmetic?

℡╲_俬逩灬. 提交于 2021-02-08 05:01:36
问题 I've found some techniques in other SO answers, but apparently I've been unable to convince SBCL to do inline fixnum arithmetic: (declaim (optimize (speed 2) (safety 1))) (declaim (ftype (function (fixnum fixnum) double-float) fixnumtest) (inline fixnumtest)) (defun fixnumtest (i j) (declare (type fixnum i j)) (let* ((n (the fixnum (+ i j))) (n+1 (the fixnum (1+ n)))) (declare (type fixnum n n+1)) (/ 1.0d0 (the fixnum (* n n+1)) ) ) ) (defun main () (format t "~11,9F~%" (fixnumtest 2 3)) )

Redefinition of the print-object method for conses has different effects in different CL implementations

吃可爱长大的小学妹 提交于 2021-01-27 19:59:46
问题 Trying to print conses not in standard list notation, but always as dotted pairs, with the minimum effort, I have redefined the method print-object in this way: (defmethod print-object((c cons) str) (format str "(~a . ~a)" (car c) (cdr c))) but the effect is different for different implementations. In Clozure CL and in LispWorks Personal the result is what I was expecting: CL-USER 1 > (defmethod print-object((c cons) str) (format str "(~a . ~a)" (car c) (cdr c))) #<STANDARD-METHOD PRINT

Common Lisp: Why does my tail-recursive function cause a stack overflow?

♀尐吖头ヾ 提交于 2020-08-04 04:06:34
问题 I have a problem in understanding the performance of a Common Lisp function (I am still a novice). I have two versions of this function, which simply computes the sum of all integers up to a given n . Non-tail-recursive version: (defun addup3 (n) (if (= n 0) 0 (+ n (addup (- n 1))))) Tail-recursive version: (defun addup2 (n) (labels ((f (acc k) (if (= k 0) acc (f (+ acc k) (- k 1))))) (f 0 n))) I am trying to run these functions in CLISP with input n = 1000000 . Here is the result [2]>

How do I memory map tmpfs files in sbcl?

笑着哭i 提交于 2020-01-14 08:08:43
问题 Exactly as the question says. I want to use shared memory to communicate between two lisp processes. Any pointers on how to do that? I can see some tutorials on doing this in clozure at :- http://ccl.clozure.com/manual/chapter4.7.html Can someone point me to a similar library to do this with sbcl? 回答1: For a portable implementation, you might want to use the osicat library, which provides a CFFI wrapper for many POSIX calls in the osicat-posix package. There is a very nice and short article

hunchentoot fatal error encountered in SBCL SIGABRT received

丶灬走出姿态 提交于 2020-01-14 04:19:25
问题 while installing hunchentoot (and subsequently loading it), I have the error: * (ql:quickload :hunchentoot) To load "hunchentoot": Load 1 ASDF system: hunchentoot ; Loading "hunchentoot" ....fatal error encountered in SBCL pid 43052(tid 0xb57dc0): SIGABRT received. Welcome to LDB, a low-level debugger for the Lisp runtime environment. ldb> I have locally built SBCL, using ./make.sh --fancy flag to have threads on my macOS % sbcl --version SBCL 1.5.9 mac os: % uname -a Darwin <m/c name> 19.0.0