Re: [Spam] Square bracket reader sytax & SBCL Win32 & Slime: How to make them work together?
Nathan Bird <[email protected]>
| Newsgroups | gmane.lisp.clsql.general |
|---|---|
| Message-ID | <[email protected]> |
On 1/26/2010 1:41 PM, Jason H wrote: On Mon, Jan 25, 2010 at 7:14 PM, Nathan Bird <[email protected] > wrote: Jason H wrote: > Hi, > > I'm learning CLSQL (4.3.0) with SBCL 1.0.33.4 Win32 and > Slime (around 2009-12-03). I have troubles using square > brackets in Slime. Entering the following into Slime's > repl buffer: > (clsql-sys:enable-sql-reader-syntax) > (select [description] :from [asnFeatureType]) > will drop me into the debugger: > The variable [DESCRIPTION] is unbound. > [Condition of type UNBOUND-VARIABLE] To rule out an error I've spotted a number of times, in the repl, try disabling the syntax a bunch of times (no seriously, 3 or 4 times), then enabling and see if it works. CLSQL tries to keep a chain of readtables, so you want to clear past that and then try enabling. Hi Nathan, Following your suggestion, here is roughly what I found: 1. With a fresh session of SBCL and Slime, evaluating (CLSQL-SYS:ENABLE-SQL-READER-SYNTAX) directly in the *slime-repl sbcl* buffer will make the square bracket reader syntax work. 2. Evaluating (CLSQL-SYS:ENABLE-SQL-READER-SYNTAX) in a file with C-c C-c will not enable sql reader syntax at all. In fact, with a fresh session of SBCL and Slime, after evaluating (CLSQL-SYS:ENABLE-SQL-READER-SYNTAX) in a file with C-c C-c, entering (CLSQL-SYS:ENABLE-SQL-READER-SYNTAX) directly in the *slime-repl sbcl* buffer won't get the bracket reader syntax work, either. Under such circumstances, the bracket reader syntax will work after you call CLSQL-SYS:DISABLE-SQL-READER-SYNTAX a few times (either in a file or in *slime-repl sbcl* buffer) and then call CLSQL-SYS:ENABLE-SQL-READER-SYNTAX in *slime-repl sbcl* buffer. As CLSQL-SYS:ENABLE-SQL-READER-SYNTAX works with straight SBCL without Slime, I'm cross posting the reply to slime-devel. Best wishes, Jason There are a couple of 'features' conspiring together to make this very unintuitive: 1. clsql:enable-sql-reader-syntax when you enable a a reader-syntax first checks to see if it is already enabled, if so don't do anything 2. When compiling files, sbcl following the specs and restores *readtable* to the value it had before compilation, see http://www.lispworks.com/documentation/HyperSpec/Body/f_cmp_fi.htm 3. Slime, when you use C-c C-c copies that portion of the file into a temp file and calls compile file on that. So what you found is when you try to use C-c C-c on the enable form, 1. sbcl puts that in a new file, compiles and runs it 2. clsql enables the syntax, copying the readtable and setting *readtable* 3. sbcl restores the readtable to the value it had beforehand 4. clsql still thinks it's enabled, so the next time you go to enable it, nothing happens. The workaround is to: * only enable the syntax through a direct call in the repl, or by using C-M-x on that form in the file (this causes slime to evaluate it as an expression, rather than compiling a mini-file) * if you see a problem, call disable a bit. * In a file, make sure an enable at the top is always matched by a disable at the bottom. I have a patch for an alternate workflow that I'll have up here in a couple of days that should be a bit less error-prone. Nathan _______________________________________________ CLSQL mailing list [email protected] http://lists.b9.com/cgi-bin/mailman/listinfo/clsql