fukamachi/clack — Issue #30: defroutes: compile time and run time messed up
Author: phanalpha
Created: 2011-10-26 04:09:37+00:00
State: open

`defroutes` (clack.app.route)
*** - ENDP: A proper list must not end with #:PARAMS12669
GNU CLISP 2.48 (2009-07-28) (built 3528290451)

I've no idea what the behavior of `defroutes` is expected. One works is here:

```lisp
(defmacro defroutes (name (env) &body clauses &aux (otherwise (car (last clauses))))
(if (member (car otherwise) '(otherwise t))
(setf clauses (butlast clauses))
(setf otherwise nil))
(with-gensyms (nil env request-method path-info patten method cb matched p)
`(defun ,name (,env)
(let ((,request-method (getf ,env :request-method))
(,path-info (getf ,env :path-info)))
(or ,@(loop :for (patten method cb) :in clauses
:collect `(multiple-value-bind (,matched ,p)
(match (make-url-rule ,patten :method ,method) ,request-method ,path-info)
(if ,matched
(funcall ,cb (concatenate 'list ,p ,env)))))
,(if otherwise
`(funcall ,(cadr otherwise) ,env)
''(404 nil nil)))))))
```

The signature of `with-gensyms` in clisp is different from others (maybe), and here I use `funcall` directly instead of `call` (could be improved if necessary).