[-lambda] Better error-handling

master
Matus Goljer 12 years ago
parent 4d67b2530e
commit 6f81492373
  1. 2
      dash.el
  2. 4
      dev/examples.el

@ -1459,7 +1459,7 @@ penalty.
See `-let' for the description of destructuring mechanism."
(cond
((not (consp match-form))
(error "match-form must be a list"))
(signal 'wrong-type-argument "match-form must be a list"))
;; no destructuring, so just return regular lambda to make things faster
((-all? 'symbolp match-form)
`(lambda ,match-form ,@body))

@ -739,7 +739,7 @@ new list."
(progn
(list a b c d)
(error "previous call should fail.")))
(error t)) => t
(args-out-of-range t)) => t
(-let [(a . (b . c)) (cons 1 (cons 2 3))] (list a b c)) => '(1 2 3)
;; final cdr optimization
(-let [(((a))) (list (list (list 1 2) 3) 4)] a) => 1
@ -772,7 +772,7 @@ new list."
(-map (-lambda ((&plist :a a :b b)) (+ a b)) '((:a 1 :b 2) (:a 3 :b 4) (:a 5 :b 6))) => '(3 7 11)
(-map (-lambda (x) (let ((k (car x)) (v (cadr x))) (+ k v))) '((1 2) (3 4) (5 6))) => '(3 7 11)
(funcall (-lambda ((a) (b)) (+ a b)) '(1 2 3) '(4 5 6)) => 5
(condition-case nil (progn (-lambda a t) (error "previous form should error")) (error t)) => t
(condition-case nil (progn (-lambda a t) (error "previous form should error")) (wrong-type-argument t)) => t
(funcall (-lambda (a b) (+ a b)) 1 2) => 3
(funcall (-lambda (a (b c)) (+ a b c)) 1 (list 2 3)) => 6))

Loading…
Cancel
Save