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

Patrick May patrick.may at mac.com
Thu Apr 1 10:59:22 PDT 2010


[ Adding OpenMCL-devel, since CCL seems to be involved somehow in this problem. ]

On Apr 1, 2010, at 10:32 AM, Nathan Bird wrote:
> On 4/1/2010 9:41 AM, Patrick May wrote:
>> 
>> 	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?
> 
> I've only really worked with SBCL so there might be something different
> in the implementations, but yes the square bracket reader syntax works
> fine for me under slime.

	Interesting.  I tried this with SBCL and it worked.  Why would ccl64 behave differently?  (Code below.)

Thanks,

Patrick

(in-package :common-lisp-user)

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

(in-package :clsql-testing)

(file-enable-sql-reader-syntax)

;(locally-enable-sql-reader-syntax)

(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+)))
   (update-records-from-instance
    (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)

;(restore-sql-reader-syntax-state)
(disconnect-pooled)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2421 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20100401/c338728d/attachment.bin>


More information about the Openmcl-devel mailing list