[plt-scheme] arg. very bizarre behavior...

From: Daniel Roy (droy at MIT.EDU)
Date: Sat Oct 4 20:38:07 EDT 2003

i think i'm having some issue related to combining schemeql and web
servlets and not knowing really what i'm doing. the wierd behavior i'm
getting is this:

the following is a snipset from schemeql's format-predicate

 (define format-predicate
    (lambda (pred)
      (unless (pair? pred)
	(raise (make-schemeql-bad-predicate-spec
                 "Bad format for predicate")))
      (let ((op (car pred))
	    (len (length pred)))
        (printf "~s~n~s~n~s~n~s~n" pred op (equal? op 'AND) len)
   . .  .

so when this is passed the string (AND (= VALID 1) (= FIELD 2)), the
printf is printing out this

(AND (= VALID 1) (= FIELD 2))

(the key line is the #f which is saying AND != AND... i've checked AND
with symbol? and i get true... (same for eq?, of course)

so this strange behavior does not occur when i run this database code from
within dr. scheme outside of the PLT web-servlet code... so here is the
code to that page ... perhaps someone more knowledgeable can point out the
glaring error i have, perhaps, linking everything together (quite honestly
, i'm confused about whether i need a compound-unit/sig, etc etc)


(require (lib "unitsig.ss")
         (lib "servlet-sig.ss" "web-server")
         (lib "servlet-helpers.ss" "web-server")
         (lib "schemeql.ss" "schemeql"))

(define connection (connect-to-database "mitdate" "dbuser" "dbpass"))

(define (search field1 field2)
  (let ((select-struct
         (query (USERNAME) "users"
                (AND (= VALID 1)
                     (= FIELD 2)))))
  (let ((result (schemeql-execute select-struct)))
    (result-cursor result))))

(unit/sig () (import servlet^)

  `(html ()
         (title () "Search Results")
         (body ()
               (h1 "Search Results")
               ,@(let loop ((cursor (search 1 #f)))
                   (if (cursor-null? cursor)
                       (append `(p ,@(cursor-car cursor))
                               (loop (cursor-cdr cursor))))))))

Posted on the users mailing list.