6,427 questions
0
votes
1
answer
56
views
How to use with-safe-io-syntax?
I'm reading a file with
uiop:read-file-lines
The documentation says: beware: be sure to use with-safe-io-syntax, or some variant thereof
This is what I tried:
(defun sample-input
()
(uiop:with-...
Tooling
0
votes
0
replies
42
views
How to get started with slimv in neovim?
I have created a plugin for lazy:
.config/nvim/lua/plugins/slimv.lua:
return {
"kovisoft/slimv"
}
Now, how do I start a REPL in neovim?
I have also created a minimal common lisp file:
...
2
votes
1
answer
87
views
I get one return value from the REPL and another from the file in Common Lisp. Why?
When I use the REPL I get this result:
* (block my-block
(print "We see this")
(return-from my-block 10)
(print "We will never see this"))
"We see this"
10
*
...
Advice
0
votes
6
replies
84
views
Adding an element to list inside a function
Lisp beginner.
I am trying to add an element to a list inside a function.
(defun add-element (e lst)
(setf lst (cons e lst)))
I cannot use the return of the function to change the original list but ...
2
votes
1
answer
101
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 ...
Advice
2
votes
2
replies
61
views
writing nicely a list of lists on disc SBCL
In a package I am developing I often get lists of lists. The single lists are very long and I would like to write them on a file controlling the output length as in the example. If I simply use (write ...
0
votes
1
answer
64
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))...
-1
votes
1
answer
67
views
CL-CFFI-GTK: Is there a way to avoid FLOATING-POINT-INVALID-OPERATION?
About three years ago I tried to follow the GTK3 tutorial for Common Lisp. I had different problems then, but many of the examples worked without any complains.
Now I took the time to reconsider it, ...
2
votes
0
answers
82
views
Avoid compiler warnings linked to double-float boxing/unboxing in SBCL Common Lisp
When I compile (with (speed 3)) the following (example) code with SBCL Common Lisp, the compiler issues this warning in relation with function triple returning a double-float:
"doing float to ...
Advice
2
votes
16
replies
206
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 ...
3
votes
3
answers
246
views
Performance issues with reading lines from *standard-input*
I need to process 100 Gigabytes of logs in a weird format, then do some analysis on the results.
Initial parts of parsing and CLI done, tried on some test data with 1 GB and it took around a minute. I ...
1
vote
1
answer
79
views
OpenBLAS gemm 2x slower in Lisp CFFI compared to direct C calls with same BLAS library
I'm experiencing a significant performance difference where OpenBLAS matrix multiplication runs 2x slower when called through Lisp CFFI compared to direct C calls, despite using the exact same ...
3
votes
3
answers
128
views
Can a symbol be aliased in Common Lisp?
Context
In Common Lisp, symbols are how names are bound to functions and variables and macros and a bunch of other stuff. I've been working with Parenscript, which is a DSL that compiles to Javascript....
1
vote
1
answer
35
views
Common Lisp: SWANK::*READTABLE-ALIST* is unbound
While working on the REPL I didn't encounter this error, but when building my program or running it from sources I did:
SWANK::*READTABLE-ALIST* is unbound
2
votes
1
answer
182
views
How do I measure performance of Lisp code?
I'm trying to discern how much performance gains I would achieve by converting Lisp (SBCL) code to assembly language. The time function on SBCL keeps giving counterintuitive results even for trivial ...
5
votes
2
answers
279
views
Signal handling in multi-threaded scenario [closed]
I'm trying to revive Hemlock, which now appears abandoned (original author has been absent for some time now). Mostly this has been a straightforward process of clearing out the bit rot, but I'm now ...
-1
votes
1
answer
104
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 ...
1
vote
0
answers
132
views
Why is single quote a terminating, instead of a non-terminating, macro character in Common Lisp?
Please correct any misapprehensions about Common Lisp syntax/parsing you see below ; I am not sure I fully understand it.
In Common Lisp, it seems you cannot have (unescaped) function or variable ...
1
vote
1
answer
67
views
In Lisp can't make-instance because :name isn't provided
This code creates an error: The slot COMMON-LISP-USER::NAME is unbound in the object
#<THING {1002B830F3}>.
I tried sbcl and clisp, both creating same problem. I can initialize instance of ash ...
1
vote
1
answer
89
views
LISP macro indentation for sub-expressions?
I'm using Emacs, and I have a macro that's like a switch for regexes, and runs an expression with variables bound to match results.
The indentation isn't what I'd like but I can't find if there's a ...
2
votes
1
answer
74
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
0
answers
64
views
Dexador (usocket, fast-http) "INVALID-VERSION: invalid HTTP version"
Anyone got this issue? A working HTTP request with Dexador now fails:
(dex:get url)
0: (FAST-HTTP.PARSER:PARSE-RESPONSE #<unavailable argument> #<unavailable argument> #<...
3
votes
2
answers
76
views
Lisp: Iterating over slots with a macro
With this:
(defclass test-class ()
((data :initarg :data)
(other :initarg :other)))
(defmethod test ((tc test-class) &key)
(macrolet ((print-slot (slot)
`(with-slots (,slot) ...
2
votes
2
answers
145
views
Parsing a word with combining diacritics in cl-ppcre
I need to parse a word that contains combining diacritics, namely the #\COMBINING_ACUTE_ACCENT. The following string "Changement de Régime" contains 21 characters, since the 16th is the ...
1
vote
2
answers
103
views
Common Lisp special variables in closure
I'm stumbling on a problem to capture special variables:
This works:
(let ((a 2))
(declare (special a))
(funcall
(lambda (x)
(declare (special a))
(+ a (* x 3)))
3))
=> 11
But ...
1
vote
2
answers
133
views
In Common Lisp, what is the correct way to define a type or nil in a class slot?
I have a class, in which I want some slots to be nil when object is created, but they should be only setable with objects of some certain type. Something like:
(defclass Something ()
((foo :initarg :...
0
votes
1
answer
70
views
ASDF "compile-bundle-op" seems to skip "package-inferred-system" projects?
I noticed that both compile-bundle-op and monolithic-compile-bundle-op work as expected on traditional projects. That is, generating the FASL files:
# compile-bundle-op FASL
<asdf-fasl-project-...
1
vote
2
answers
96
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+ ...
1
vote
2
answers
66
views
Undefined variable: COMMON-LISP-USER::0.25% in macro when I expected the symbol to not be evaluated
I have a macro to define initialization variables to the program. The macro is ...
(defmacro defparm (var value &key (frequency nil) (date nil date-supplied-p))
"Macro to define starting ...
1
vote
1
answer
115
views
Can the inner workings of a Common Lisp macro be made evident with more than macroexpand(-1)?
I have this macro:
(defmacro if (test-form &body body)
(let ((test (gensym)))
`(let ((,test (cl:if (booleanp ,test-form)
(cl-truth ,test-form)
...
2
votes
2
answers
80
views
Is there a way to get the effect of SLIME-REPL-CLEAR-BUFFER within Common Lisp
I once read somewhere, that we can set a global Emacs variable to T (or NIL, I don't know) in order to (roughly) make Emacs accessible from Common Lisp.
This information was in company with the ...
3
votes
1
answer
73
views
Is it possible to test for no return value?
The output of the following function is suppressed:
(defun foo ()
()
(values))
So in the REPL this happens of course:
CL-USER> (foo)
; No value
I don't get the idea how to test that a ...
1
vote
1
answer
77
views
ASDF:REQUIRE-SYSTEM -> Deprecated and to avoid und all circumstances, or not?
I'm starting to delve into Common Lisp's ASD Facility and am wondering, whether asdf:require-system is still useful in the described way.
That is: With this function it is "appropriate to load ...
0
votes
1
answer
85
views
Safari won't connect to my bare bones webserver
I am testing a minimal web server in SBCL using usocket:
(defun create-server (port)
(let* ((socket (usocket:socket-listen *hostname* port))
(connection (usocket:socket-accept socket :element-...
1
vote
1
answer
110
views
Common Lisp: Why does `WITH-SLOTS` allow shorthand names, but `WITH-ACCESSORS` doesn't?
I've noticed an interesting difference between WITH-SLOTS and WITH-ACCESSORS in Common Lisp:
WITH-SLOTS allows a shorthand syntax:
(with-slots (slot1 (var-name slot2)) instance
...)
But WITH-...
3
votes
2
answers
35k
views
Do you have to (ASDF:load-system :xxxx) and (ql:quickload :yyyy) everytime you want to work?
I'm missing an obvious part of ASDF / quickload / sly, and it's starting to drive me nuts.
It's mostly about the developer experience, but as I can't go past the very first steps, I'm unable to work ...
1
vote
1
answer
88
views
Allegro CL unexpected behavior of READ-SEQUENCE
I am working with Allegro CL 11.0 Express Edition on Linux (Ubuntu 16.04). I am seeing behavior from READ-SEQUENCE which is surprising to me. Is the following conforming to the CLHS? EDIT: Franz, Inc. ...
1
vote
1
answer
67
views
Getting function arglist in SBCL Lisp
In SBCL when I describe a lambda I get a bunch of detail:
* (setf f (lambda (a b) (* a b)))
#<FUNCTION (LAMBDA (A B)) {535B3C3B}> ...
2
votes
0
answers
161
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 ...
2
votes
2
answers
115
views
How do I correctly capitalize words that contain non-alphanumeric characters in Common Lisp?
Thanks in advance for the help!
Here's the situation:
I want to capitalize the first word in a sentence. I have the individual words in a sentence, stored as strings. In the case of the first word, I ...
2
votes
1
answer
46
views
Access constant defined in a file loaded with load
I have this lisp file:
(load "constants.lisp")
(defpackage :my-package
(:use :cl))
(in-package :my-package)
(format t "Constant value: ~A~%" my-constants:+my-constant+)
And ...
0
votes
3
answers
94
views
Common Lisp: Why does using read-from-string create two REPL outputs?
I have been learning Common Lisp for a short while, using the SBCL 2.0.0 REPL on a Windows 10 machine. At one point in time I inputted the 2 following lines into a REPL:
(defvar var-string (print (* 5 ...
1
vote
1
answer
150
views
What is the difference between CLISP and SBCL in handling closures and lexical variables?
(Edit 2025-02-27: I should note that there isn’t a difference between how CLISP and SBCL handle this situation the way I initially thought there was; see the comments to this question, and the answer ...
1
vote
1
answer
76
views
How to use the format control arguments ~< ~> ~I correctly for a tree-like set of clos objects from within print-object method?
I think I did this right in the past, but this time, I am kind of stuck...
The code below is the CLOS style structure of a rope. Which in essence is a binary tree.
For printing purposes, I would like ...
0
votes
1
answer
125
views
Stack Overflow with BFS LISP
I have created a search function following the BFS algorithm but found a problem, it works fine on other problem domains but on this problem domain I am only getting stack overflows.
This specific ...
1
vote
1
answer
61
views
access lexical scope from macrolet body forms
i have a use case for a code walker. in my case, I want something that can analyse an expression at runtime and determine if it directly calls any of a small set of functions (let's say a single ...
0
votes
0
answers
63
views
Successfully setting up TPS on MacOS
I'm following the instructions from the following website, to install their Theorem Proving System software, to complement a book that's recommended to my course.
This can be found here: Downloading ...
4
votes
3
answers
250
views
Is there something akin to Common Lisps "special variable" in Rust?
The code I am working on is single threaded, but for the sake of this question, this is secondary.
In Common Lisp, there is a (in my eyes) cool feature, called special variables and it goes like this:
...
0
votes
1
answer
116
views
How is defconstants and symbol macros handled in Common Lisp in regard to space?
When interfacing with C libraries, in this case win32 in particular, there may be a large number of defined constants. In a C/C++ program these are just literal numbers when compiler sees them, the ...
1
vote
1
answer
94
views
How to access slots within a class?
Given a class definition, is it possible to define one slot in terms of another, similar to how I would do it with let*?
For example, I would like to be able to do something like this (which obviously ...