common-lisp

Trying to learn: Object Reorientation, and generic functions in LISP!

Hi, im reading Practical common Lisp as a result of another question. I just read chapter 16 and 17 where you can find how LISP manages objects. But after a couple of years of thinking how Java manages objects, i cant really seem to understand how you would implement bigger architectures in LISP using the CLOS. So i ask you guys for s...

How do I get a common-lisp GUI in Windows?

I'm using Emacs, with CLISP and Slime, and want to be able to draw pictures on the screen. I'm specifically thinking about drawing graphs, but anything that would let me draw basic shapes and manipulate them would be able to get me started. ...

Dynamic and Lexical variables in Common Lisp

I am reading the book 'Practical Common Lisp' by Peter Seibel. In Chapter 6, "Variables" sections "Lexical Variables and Closures" and "Dynamic, a.k.a. Special, Variables". http://www.gigamonkeys.com/book/variables.html My problem is that the examples in both sections show how (let ...) can shadow global variables and doesn't really te...

Lisp image

Essentially, I would like to know what a Lisp image is? s it a slice of memory containing the Lisp interpreter and one or more programs or what? ...

Does any Common Lisp function return 3 values?

Does any Common Lisp (builtin) function return more than 2 values? I know many that return 2, but I can't think of one that returns 3. (I saw a comment here about returning more than 2 values, and tried to think of a case where CL did this, but can't.) ...

Can I reference other slots in a defstruct?

In common lisp I've noticed that I can write this: (defun foo (&key (a 1) (b 2) (c (+ a b))) (print (+ a b c))) And when I call (foo), 6 is printed. So the argument c can refer to values set for a and b. But I can't seem to find a way to do something similar with defstruct. Something like: CL-USER> (defstruct thing a b c) THING CL-...

In Common Lisp, why do multi-expression bodies of (if) statements require (progn)?

Is this just a bit of historical cruft left over from the 1950s or is there some reason syntactically why multi-expression bodies of (if) forms require (progn)? Why can't you wrap the multiple expressions in a set of parentheses like with (let): (if some-cond ((exp1) (exp2) (exp3)) ; multi exp "then" (exp4)) ; single exp "e...

Best web framework in Common-lisp?

What is the best common-lisp web framework available? I'm looking for something that's suitable for developing commercial web applications and capable of handling high traffic sites similar to Stack Overflow. It should also have built-in session handling and other similar features. ...

Simpson's Integral in Common Lisp

Hello all, I just wrote a simple Common Lisp program to find out Simpson's Integral: ;Integration by Simpson's rule; CL code ;Found to be working correctly with 'clisp' (defun simpsons(f a b n) (defparameter *summation* 0) (defvar *h* (/ (- b a) n)) (loop for k from 2 below (- n 1) by 2 do (setf *summation* (+ *summation* ...

What is wrong with the following Common Lisp macro using gensym?

Learning Common Lisp (using GNU CLISP 2.43) .. so might be a noob mistake. Example is the 'print prime numbers between x and y' (defun is-prime (n) (if (< n 2) (return-from is-prime NIL)) (do ((i 2 (1+ i))) ((= i n) T) (if (= (mod n i) 0) (return NIL)))) (defun next-prime-after (n) (do ((i (1+ n) (1+ i))) ...

LET versus LET* in Common Lisp

I understand the difference between LET and LET* (parallel versus sequential binding), and as a theoretical matter it makes perfect sense. But is there any case where you've ever actually needed LET? In all of my Lisp code that I've looked at recently, you could replace every LET with LET* with no change. Edit: OK, I understand why so...

How to programmatically insert comments into a Microsoft Word document?

Looking for a way to programmatically insert comments (using the comments feature in Word) into a specific location in a MS Word document. I would prefer an approach that is usable across recent versions of MS Word standard formats and implementable in a non-Windows environment (ideally using Python and/or Common Lisp). I have been looki...

SBCL and clisp

When I started learning CL from Practical Common Lisp, as is preached in the book, I started off with Allegro CL compiler. I stopped using it, since its commerical, yet free bit didn't impress me. It needed a connection to its remote server for some licensing stuffs. I switched to 'clisp' and am using it. Now, I have been hearing about ...

Common Lisp equivalent to C enums

I'm trying to learn some Lisp (Common Lisp) lately, and I wonder if there is a way to give constant numbers a name just like you can do in C via enums. I don't need the full featureset of enums. In the end I just want to have fast and readable code. I've tried globals and little functions, but that always came with a degration in perf...

How can ECL include ASDF dependencies in an executable?

I have this ecl-make.lisp: (asdf:oos 'asdf:compile-op :stumpwm) (defun system-objects (system) (loop for component in (asdf:module-components (asdf:find-system system)) for pathname = (asdf:component-pathname component) for directory = (pathname-directory pathname) for name = (pathname-name pathname) when (equal "lis...

Porting Common Lisp code to Clojure

How practical is it to port a Common Lisp application to Clojure? To be more specific, what features exist in Common Lisp that do not exist in Clojure, and would have to be re-written? ...

How to convert byte array to string in Common Lisp?

I'm calling a funny API that returns a byte array, but I want a text stream. Is there an easy way to get a text stream from a byte array? For now I just threw together: (defun bytearray-to-string (bytes) (let ((str (make-string (length bytes)))) (loop for byte across bytes for i from 0 do (setf (aref str i) (code-c...

Linearly recursive list-difference function in Common Lisp.

I was going through this tutorial for fun, and got stuck on the very last thing he says, "Exercise: Give a linearly recursive implementation of union and difference." (for a list) Union, no sweat. Difference, sweat. An attempt looks like this. . . (defun list-diff (L1 L2) (cond ((null L1) L2) ((null (member (first L1) L2...

Slots in CLOS

Could any CL'er please explain 'slots' in CLOS? I am finding it difficult to understand the part after the slot name. That is in : (defclass foo () (data1 :initarg foo)) What do the 'initarg' and other such similar things mean? I am re-reading manuals. So, I would really appreciate if any of you here could explain it to a layman like ...

Common Lisp: Working with &rest parameters

Can anyone tell me how to work with the parameters stored in the value specified by &rest. I've read around a lot and it seems as if authors only know how to list all the parameters as so. (defun test (a &rest b) b) This is nice to see, but not really that useful. The best I've found so far is to use first, second, and so on to get ...