Questions tagged [ansi-common-lisp]

This is a synonym for common-lisp.

19 questions
9
votes
2 answers

SBCL changes EQness of a local bound function object, even though it is not set?

Given this example code (from a Reddit /r/lisp question): (defun next (pos) (nth (1+ pos) '(0 1 2 3 4 5 6 7 8 9 10))) (defvar *next* (function next)) (let ((old-next #'next) (previous (make-hash-table))) (format t "~% 1 EQ? ~a"…
Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
5
votes
3 answers

error about optional-arguments in common-lisp

SBCL 64bit, 1.1.7 If I want to create a package and use a little symbols from package :CL, I will create a package like this one: (defpackage :foo (:import-from :cl :defun :defmacro :in-package :null :car :cdr…
xiepan
  • 623
  • 4
  • 13
4
votes
1 answer

How can conditions be handled in GCL?

handler-case is key to handling conditions in Common Lisp, but GCL 2.6.12 on Ubuntu 18.04 considers it to be an undefined function: >(handler-case (error "test") (error (condition) condition)) …
4
votes
1 answer

how to define and call class methods in common lisp / CLOS

I'd like to define methods on class objects, that inherit based upon the class' ancestry in the same way that instances' methods inherit. Is there some way to do this? Here's what's not working: eql-method specialization. Consider this…
Dave Morse
  • 717
  • 9
  • 16
4
votes
1 answer

apply & funcall - the different results

ANSI Common Lisp. Why I get an other answer in the last case? (list 1 2 3 nil) ; (1 2 3 nil) (funcall (function list) 1 2 3 nil) ; (1 2 3 nil) (apply (function list) '(1 2 3 nil)) ; (1 2 3 nil) (apply (function list) 1 2 3 nil) ; (1 2 3)
Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
3
votes
0 answers

Recommended way to deal with cross-platform file paths with support for URLs?

I'm not new to Lisp but new to CL and a bit confused by the file and directory path handling. What I need: A completely cross-platform way to deal with file and directory paths that can be specified in URLs and stored in a database (preferably as…
3
votes
2 answers

Lisp good practices

I've started studying Lisp 2 days ago and I'm reading Paul Graham's ANSI Common List, which exposes the language structure in a very interesting way. It's not too much theoretical for beginners, and not too shallow (as Sierra-Bate's Head First Java,…
3
votes
1 answer

Does #'adjoin in Common Lisp work as per HyperSpec when used with `:key`?

Looking at the docs for #'adjoin in the HyperSpec, I see the following in the Examples section: (setq slist '()) => NIL (setq slist (adjoin '(test-item 1) slist)) => ((TEST-ITEM 1)) (adjoin '(new-test-item 1) slist :key #'cadr) => ((TEST-ITEM…
Adrian
  • 741
  • 4
  • 14
2
votes
2 answers

Installing Quicklisp libraries in a Docker image

Is there a Dockerfile for installing cl-json (or other Quicklisp library) on Docker? Most installation instructions I've seen require user input on commands with no --noinput flag, making it difficult to install through a Dockerfile. In addition,…
Will
  • 1,171
  • 2
  • 14
  • 26
2
votes
1 answer

Accessing vectors in common lisp

(setf vec (make-array 4 :initial-element nil)) (svref vec 0) In the above snippet we create a vector of length 4 and access its elements by (svref vec ). (vector 1 2 3 4 5) In the above snippet we create a vector of length 5 using vector function.…
2
votes
3 answers

How to call a method object with standard functions

How does one call a method object as a function? Closer-mop and clos packages both provide method-function for turning a method object into a function. However, is there a way to do it without including another package? And if not, which package?…
user3446498
2
votes
2 answers

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

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…
Renzo
  • 26,848
  • 5
  • 49
  • 61
1
vote
3 answers

How to create an array of function pointers in Common Lisp?

I have a program that requires having a series of interchangeable functions. In c++ I can do a simple typedef statement. Then I can call upon on a function in that list with function[variable]. How can I do this in Common Lisp?
1
vote
4 answers

Is there a way to use iteration in Common Lisp and avoid side-effects at the same time?

I've written two versions of a lisp function. The main difference between the two is that one is done with recursion, while the other is done with iteration. Here's the recursive version (no side effects!): (defun simple-check (counter list) "This…
progner
  • 139
  • 5
0
votes
1 answer

Why does set-difference in sbcl common-lisp appear to be destructive?

The following code snippet compiles under SBCL 2.2.3 (using Emacs/SLIME, C-c C-k), and the .fasl is loaded without errors. On a subsequent call to test-sets in the REPL, the value of *evens* is set to *all*. Reading the documentation I could find, I…
1
2