[slime-devel] Slime, CLSQL, and reader macros

Patrick May patrick.may at mac.com
Thu Apr 1 13:41:02 UTC 2010

	This is a follow up to a question I asked recently on the CLSQL list.  I think the problem is my mental model of Slime.

	My environment is OS X 10.6.3, Clozure 1.3-r12755M, PostgreSQL 8.4.1, and CLSQL 5.0.5.

	My problem is with the CLSQL square bracket syntax in Slime.  If I run the code below from a REPL started at the command line, it works fine.  I can use either the file-enable-sql-reader-syntax or the locally-enable-sql-reader-syntax / restore-sql-reader-syntax-state pair fine.  When I evaluate the same code in Slime with C-x C-e or C-c C-r, however, I get this error when defining add-customer:

;Compiler warnings :
;   In ADD-CUSTOMER: Undeclared free variable [=
;   In ADD-CUSTOMER: Undeclared free variable [ID]
;   In ADD-CUSTOMER: Undeclared free variable ID]

and this error when trying to add a customer object:

Unbound variable: [=
   [Condition of type UNBOUND-VARIABLE]

This happens with either way of enabling the square bracket syntax.

	Am I misunderstanding something fundamental about Slime?  Has anyone managed to use Slime for CLSQL development with the square bracket syntax?



(in-package :common-lisp-user)

(defpackage :clsql-testing
  (:use :common-lisp

(in-package :clsql-testing)



(def-view-class customer ()
  ((id :db-kind :key
       :db-constraints :not-null
       :initarg :id
       :reader id
       :type integer)
   (name :db-constraints :not-null
         :initarg :name
         :reader name
         :type string)
   (phone-number :db-constraints :not-null
                 :initarg :phone-number
                 :accessor phone-number
                 :type string))
  (:base-table "test_customer"))

(defconstant +id-sequence+ "id_sequence")

(defun add-customer (name phone-number)
  "Add a customer."
  (let ((id (sequence-next +id-sequence+)))
     (make-instance 'customer
                    :id id
                    :name name
                    :phone-number phone-number))
    (first (select 'customer :where [= [id] id] :flatp t))))

(connect '("localhost" "db-name" "user" "password")
         :database-type :postgresql-socket
         :if-exists :new
         :pool t)

(defparameter customer-foo (add-customer "Test Customer Foo" "0123456789"))
(id customer-foo)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2421 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/slime-devel/attachments/20100401/17074c23/attachment.bin>

More information about the slime-devel mailing list