918 questions
2
votes
1
answer
67
views
Common Lisp step-by-step debugging with SBCL and SLIME
I tried to debug the function below (find-3rd-largest), and wanted to execute expressions step by step from (break), as I did for other programming languages.
So, I compiled the function with C-u C-c ...
0
votes
1
answer
52
views
Why Common Lisp warns about unknown keyword argument in some cases but not others?
I am trying to understand why when I declare types, things seem to go very wrong in SBCL.
Here's a little file I created to reproduce the problem:
(defpackage p1 (:use :cl) (:export #:do-it #:keytype))...
Advice
1
vote
16
replies
191
views
In Common Lisp, replacing "get-setf-method" with "get-setf-expansion" is not always working
The sortf function from Chapter 12 of the book "On Lisp" originally used get-setf-method, which is currently unavailable in a recent SBCL by default.
Therefore, get-setf-expansion was used ...
-1
votes
1
answer
101
views
I can't see why Steel-Bank Common Lisp thinks a string is a function in my code [closed]
I am using a Windows 11 computer, running Steel Bank Common Lisp (version 2.0.0) in PowerShell by inputting functions directly into the SBCL.exe REPL to see if they work. In the process, I have hit ...
2
votes
1
answer
73
views
Let-binding *read-default-float-format* not having effect in another thread?
I don't know if I am clear in the title, but here me out. I have a package in which I bind *read-default-float-format* to 'double-float.
So far so good. When I load the library into fresh SBCL process ...
1
vote
2
answers
94
views
Is `eval-when` required for `defconstant` used in `#.` reader macro?
You can use the #. reader macro to get symbolic case labels in Common Lisp. Example:
(defconstant +foo+ 1)
(defconstant +bar+ 2)
(defun quux (x)
(ecase x
(#.+foo+ "Foo!")
(#.+bar+ ...
2
votes
0
answers
140
views
Efficient logical shift for bit arrays?
The Common Lisp standard includes bit arrays and logical operations on them, such as bit-ior, bit-and,...
What the standard does not seem to offer is logical shifting of bit arrays.
Of course, this ...
0
votes
0
answers
31
views
How can I access programatically a file saved in one Drive
I work with SBCL Common lisp. Sometimes I need to open a file for writing or reading. When these files are saved by Excel to One Drive, which is required for continuous updating, I don't know how to ...
7
votes
1
answer
408
views
Inconsistent results in SBCL
Consider the following Common Lisp code.
(print (let* ((x nil) (y x)) (setq x t) (and y x))) ; T
(print (let* ((x nil) (y x)) (setq x t) (and x y))) ; NIL
(print (let* ((x nil) (y t)) (setq y x) (...
1
vote
1
answer
87
views
find-symbol requires explicit package name
Solving a challenge in www.codewars.com.
It uses sbcl and rove for testing the answers.
I want to translate a string to a symbol. Codewars requires code inside a package to see it. This is a sample
(...
0
votes
1
answer
22
views
Common Lisp setting *print-circle* T causes list compression?
(setq *print-circle* T)
;; then create some list with a large number of items, of which a bunch
;; of them repeat
If you then try to print the list in the repl, you will see a lot of unfamiliar text....
1
vote
1
answer
68
views
ASDF system uffi does not return version number
I successfully did load clsql with quicklisp. Loading of a source file with function definitions, which use clsql, was also successfull. When executing a clsql function I am getting this error.
(clsql:...
0
votes
0
answers
122
views
How do I help SBCL find libcrypto (and some other libraries)?
I have just upgraded to SBCL 1.4.3, and I'm having trouble loading foreign libraries while loading my package with Quicklisp. Everything worked before the upgrade.
I get this error:
(CFFI::FL-ERROR &...
1
vote
2
answers
190
views
How do I ask a CommonLisp system to lookup symbols dynamically at runtime in compiled functions?
As a preamble, I am implementing two simple commands I can use via a little package in SBCL, which emulates Allegro repl. The package is sb-aclrepl, found in the contrib folder in SBCL sources. The ...
1
vote
1
answer
228
views
How to modify a lexical environment at runtime in Common Lisp?
In Common Lisp, is it possible to programmatically manipulate a lexical environment at runtime?
If I create a closure, typical let-over-lambda, as described in D. Hoytes LOL-book, how can I augment ...
1
vote
1
answer
120
views
How to make Firefox render HTML generated on a local server written in Common Lisp?
My goal is something akin to Chapter 12 of Land Of Lisp: using the usocket package in SBCL I want to write a local server that I can connect to with my browser. I started from a helpful example:
#!/...
1
vote
0
answers
49
views
Duplicate log output from log4cl in multi-threading
I got this weird issue that log4cl output duplicate logs in thread functions when running as script:
#!/usr/bin/sbcl --script
(require :asdf)
(require :log4cl)
(log:config :debug)
(log:info "...
3
votes
1
answer
233
views
UTF-8 string has too many bytes using SBCL and babel on Windows 64 bits
The UTF-8 string in example seems to be coded with too many bytes!
The input string: "👉TEST📍TEST"
“👉” (U+1F449): A hand pointing right
“T”, “E”, “S”, “T”: Basic Latin letters
“📍” (U+...
2
votes
1
answer
68
views
in SBCL why does setting *print-circle* to T in LET in common lisp not work, but SETF does print circular list fine?
I noticed that if I setf *print-circle* to T, then it prints circular list:
CL-USER> (setf *print-circle* t)
T
CL-USER> (let ((x (list 1)))
(setf (cdr x) x)
x)
#1=(1 . #1#)...
3
votes
1
answer
83
views
SBCL REPL Wrong Reuse of Cons Cells?
What's going on in the interaction with SBCL REPL below (the last form)?
TEST> (acons 'k 'v1 nil)
((K . V1))
TEST> (assoc 'k *)
(K . V1)
TEST> (push 'v2 (cdr *))
(V2 . V1)
TEST> (cdr '(K . ...
1
vote
0
answers
146
views
Reading hash table from file fails
I wrote a custom reader macro for printing hash tables:
#| Custom printer for hash tables |#
;; object = hash table
;; stream = output stream
(defmethod print-object ((object hash-table) stream)
(...
2
votes
1
answer
168
views
Why can't SBCL determine the upgraded-array-type of elements of a string at compile-time?
I'm finding that SBCL (2.4.0, on x86-64 Linux) is having trouble optimizing character accesses in strings. The following code
(compile
nil
'(lambda (s)
(declare (optimize (speed 3))
...
0
votes
0
answers
56
views
Making an SBCL program stop [duplicate]
I used to have a function in GNU clisp like this:
(defun showVersion()
(let ((currentVersion 1.0))
(format t "My software current version: ~a.~%" currentVersion))
) ; End of ...
2
votes
2
answers
123
views
Set variables declared through let* as ignorable
I am trying to write a macro that would generate code that looks like:
(defun test ()
(let* ((_ (exp1))
(_ (exp2))
...
(_ (expn)))))
The (expn) calls might be ...
1
vote
0
answers
108
views
How can I pause a thread or save an image of a thread in Common Lisp?
I'd like to be able to pause the execution of a computationally intensive thread when the user clicks a pause button and pick up where it left off when the user clicks on a button to resume ...