Skip to content

Commit

Permalink
Mark CONDLET as not working.
Browse files Browse the repository at this point in the history
I'll have to fix it later, but this way there will be no confusion, it
will produce an error if you attempt to use it.
  • Loading branch information
smithzvk committed Nov 5, 2013
1 parent c62f3bf commit 7e35b08
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions on.lisp
Expand Up @@ -889,30 +889,35 @@ don't. Lists are returned as multiple values."
;; `(,(car cl) (let ,(cdr cl) ,@body)) )
;; clauses ))) )

;; (with-compilation-unit (:override nil)
(defmacro condlet (clauses &body body)
"Conditional bindings"
(let ((bodfn (gensym "CONDLET-"))
(vars (mapcar #'(lambda (v) (cons v (gensym "CONDLET-")))
(remove-duplicates
(mapcar (lambda (x) (if (listp x) (car x) x))
(mappend #'cdr clauses) )))))
`(labels ((,bodfn ,(mapcar #'car vars)
,@body ))
(cond ,@(mapcar #'(lambda (cl)
(condlet-clause vars cl bodfn) )
clauses )))))

(defun condlet-binds (vars cl)
(mapcar #'(lambda (bindform)
(if (consp bindform)
(cons (cdr (assoc (car bindform) vars))
(cdr bindform) )))
(cdr cl) ))

(defun condlet-clause (vars cl bodfn) ;; Modified to remove unecessary binds
`(,(car cl) (let ,(condlet-binds vars cl)
(,bodfn ,@(mapcar #'cdr vars)) )));; )
(defmacro condlet (clauses &body body)
"Conditional bindings"
(error "This is broken, you really need to fix it.")
;; We need to allow for nil bindings for atoms in the binding list.
(let ((bodfn (gensym "CONDLET-"))
(vars (mapcar #'(lambda (v) (cons v (gensym "CONDLET-")))
(remove-duplicates
(mapcar (lambda (x) (if (listp x) (car x) x))
(mappend #'cdr clauses) )))))
`(labels ((,bodfn ,(mapcar #'car vars)
,@body ))
(cond ,@(mapcar #'(lambda (cl)
(condlet-clause vars cl bodfn) )
clauses )))))

(defun condlet-binds (vars cl)
(mapcar #'(lambda (bindform)
(if (consp bindform)
(cons (cdr (assoc (car bindform) vars))
(cdr bindform) )))
(cdr cl) ))

(defun condlet-clause (vars cl bodfn) ;; Modified to remove unecessary binds
`(,(car cl) (let ,(condlet-binds vars cl)
(,bodfn ,@(mapcar
;; This needs to either send the bound symbols, or
;; send the unbound original symbol through. This
;; CDR doesn't cut it
#'cdr vars)) )));; )

(defmacro if3 (test t-case nil-case ?-case)
"Like if except allows for an ambiguous result if the predicate returns ?"
Expand Down

0 comments on commit 7e35b08

Please sign in to comment.