[plt-scheme] Syntax && SchemeQL

From: Ryan Culpepper (ryan_sml at yahoo.com)
Date: Thu May 20 14:33:52 EDT 2004

--- Toon Verwaest <camden at camden.be> wrote:
> I'm trying out the SchemeQL, but it still seems to have a few
> bugs...
> One of the things I can't figure out how to fix it:
>   (define-syntax (add-constraint-to-table! stx)
>       (syntax-case stx ()
>             [(_ table . cons)]
> 	    (syntax
> 	    	(let  ((tab (quasiquote table))
> 		       (con (quasiquote cons)))
> 	  (if (table-definition? tab)
> 	      (begin (set-table-definition-constraint!
> 		      table
> 		      (map format-table-named-constraint con))
> 		     table)
> 	      (raise-type-error 'add-check-to-table "table-definition
> structure" tab))))]))
> When I call this, I can send stuff to the . cons part, with
> unquote, but the table I can't unquote.
> I don't really know how the syntax-stuff works, but I would think
> from the (quasiquote table),
> that table should be able to have an unquote also..
> When I run it with unquote, it just says: not in quasiquote.

I haven't examined the SchemeQL code, but this snippet looks like it
should be using the local variable "tab" instead of the pattern
variable "table" within the body of the let.

Try replacing the code with this:

(define-syntax (add-constraint-to-table! stx)
  (syntax-case stx ()
    [(_ table . cons)]
       (let  ((tab (quasiquote table))
              (con (quasiquote cons)))
         (if (table-definition? tab)
             (begin (set-table-definition-constraint!
                      tab ;; CHANGED!
                      (map format-table-named-constraint con))
                    tab) ;; CHANGED!
             (raise-type-error 'add-check-to-table 
                               "table-definition structure"

Hope that helps,

Do you Yahoo!?
Yahoo! Domains – Claim yours for only $14.70/year

Posted on the users mailing list.