lisp

Does 'require' in elisp/lisp prevent from reloading libraries?

For C/C++, people use #ifdef .. #endif technique to prevent reloading libraries, and Objective-C uses import to do the same thing. How about lisp/elisp? If (require 'cl) is used before, and (require 'cl) is seen somewhere, lisp is clever enough not to load it again? Or, is there any way to prevent this reloading libraries? ...

Book for learning how to write Clojure/Lisp Macros

Hey, I'm reading "Programming Clojure" and I'm interested in a book that discusses how to create macros as extensive as possible. Do you suggest a book for this? Thanks. ...

Tasks unsuited for dynamic scoping

Hi! Can you give me some examples of tasks unsuited for dynamically scoped lisps? I'm failing to see how the Lexical scope is so much better and not just a matter of changing the coding style, so I'd love to code something and see it with my own eyes. Thanks! ...

Scheme dialect of Lisp in Emacs

How do I get the EMACS lisp interpreter use the Scheme dialect of LISP. I am going over the SICP book and am new to EMACS (just finished learning the navigation and file access commands)? ...

clsql connect oracle database

Hi, I am doing some practice with clsql. I want to connect my oracle server hence my connection function is; (connect '("192.168.2.3" "xe" "username" "password") :database-type :oracle) when i hit the return, the following error message shows up. Couldn't load foreign libraries "libclntsh", "oci". (searched *FOREIGN-LIBRARY-SEARCH-PA...

What is the difference between a variable and a symbol in LISP?

In terms of scope? Actual implementation in memory? The syntax? For eg, if (let a 1) Is 'a' a variable or a symbol? ...

Q about Problem 19-2 in "Lisp" by Winston and Horn

Problem 19-2 in "Lisp" by Winston and Horn states, In depth-first search, all of the partial paths in the queue at a given point in the search are related to one another in a simple way: each is the extension by one node of the partial path after it in the queue. The queue might, for example, look like this: ...

Dr Racket problems with SICP

I'm working through SICP. Currently, in the first chapter, I'm having problems getting Racket to let me redefine "primitives". For instance, I was under the impression that I should be able to arbitrarily do "(define + 5)" and that would be fine or redefine the sqrt procedure. Instead, I get this: "define-values: cannot change constant v...

How is my LISP function an unbound variable?

I define a function in LISP, and it defines correctly. But whenever I try to call it, I get an error saying "The variable FACTORIAL is unbound." I have tried this on both OS X and Windows 7, on LispWorks and Allegro. The function is - (defun factorial (x) (if (= 1 x) 1 (* x factorial (- 1 x)))) Any help is appreciated. ...

Multiple (define)s in a CL style macro [scheme]

I'm currently learning how to write CL style macros (define-macro) in Scheme. As a simple example, I wrote a struct macro that defines functions like make-thing, thing?, thing-field accessors and so on. Now I'd like to combine multiple defines in a single macro, but only the last one is actually used. Currently I'm using eval to define ...

Emacs nXhtml Bugging Out

I was recently browsing around for an emacs mode for php and the like and decided to settle on nXhtml. However, I keep getting the following error: whenever I open up an html file, the entire file is highlighted in blue. Needless to say, this is quite the annoyance. I figure it's probably because my html files don't have any xhtml spe...

How to extend emacs lisp mode with indentation changes and color changes

Im making a DSL in lisp (basically what i think is a nicer syntax), its the same thing as lisp except with different 'primitives', no instead of not, 'as' instead of let.Thus i need to change both indentation and color only in files which end in .goby (it should not effect ones which end in .lisp) So i would like to create files with ex...

Function Erroneously Returning Nil

I'm trying to learn Lisp now, as a supplement to my CS1 course because the class was moving too slow for me. I picked up "Practical Common Lisp," which so far has turned out to be a great book, but I'm having some trouble getting some examples to work. For instance, if I load the following file into the REPL: ;;;; Created on 2010-09-01 ...

How can I do setf on a struct's accessors when using intern

I'd like to setf different fields of a struct depending on a certain variable. I decided to use the following approach: Generate a string with the field's accessor name: (setq my-string (format nil "STRUCT-ESTADISTICAS-NUM-~S" x)) and then use intern with funcall: (funcall (intern my-string) *estadisticas*) This call returns t...

In clojure, is (= 'a 'a) referring to the 'same atom'?

In some implementations of Common LISP we can say that for the following expression (eq 'a 'a) Is true because 'a and 'a are the "same atom". This may be implementation dependent, but it seems the phrase (used in a popular LISP teaching book) assumes that atoms of the same value are stored in the same location in memory. In Java, ...

What is the difference between an atom in Common Lisp and an atom in Clojure?

The following page talks about how atoms work in Clojure. It doesn't say a whole lot about the differences between atoms in Clojure and other lisp dialects. What is the primary difference between an atom in Common Lisp and an atom in Clojure? (What is missing from the definition of atom in Clojure that exists in CL?) ...

Apply-recur macro in Clojure

I'm not very familiar with Clojure/Lisp macros. I would like to write apply-recur macro which would have same meaning as (apply recur ...) I guess there is no real need for such macro but I think it's a good exercise. So I'm asking for your solution. ...

Python decorators compared to CLOS "around" method.

Hi, I'm reaching back to my CLOS (Common Lisp Object System) days for this abstract question. I'm augmenting the question to clarify: It appears to me that a Python decorator is sort of like an "around" method in CLOS. From what I remember, an "around" method in CLOS is a method/function that wraps around the primary method/functi...

Let: creating a temporary variable in Common Lisp

Given a function: (defun foo (bar) (let ((baz bar)) (setf baz (+ baz 1))) I have been given to understand (perhaps incorrectly?) that baz becomes some sort of reference to bar, instead of being a true copy of bar. What I would like to do is create a true temporary variable so that I can ensure that I can muck about with the pass...

More generic lisp code to generate combinations of pairs

Given this sad thing below, which generates all pairs of only two ranges - [53]> (setq thingie '()) NIL [54]> (loop for i in (generate-range 0 3) do (loop for j in (generate-range 4 6) do (push (list i j) thingie))) NIL [55]> thingie ((3 6) (3 5) (3 4) (2 6) (2 5) (2 4) (1 6) (1 5) (1 4) (0 6) (0 5) (0 4)) [56]> Or, put anothe...