patched version from Jens (PR7824)
svn: r2440
This commit is contained in:
parent
6cef2e9230
commit
208a463112
|
@ -5,8 +5,6 @@
|
|||
|
||||
; Examples of errors with better error messages:
|
||||
; (cut)
|
||||
; (cut <>)
|
||||
; (cut <...>)
|
||||
; ((cut cons <> <>) 1 2 3)
|
||||
|
||||
(module cut mzscheme
|
||||
|
@ -55,13 +53,23 @@
|
|||
[(cut)
|
||||
(raise-syntax-error #f "cut expects 1 or more slots or expressions, given none" stx)]
|
||||
[(cut <>)
|
||||
(raise-syntax-error #f "cut expects an expression at the first position, given a slot <>" stx)]
|
||||
#'(lambda (f) (f))]
|
||||
[(cut <...> slot-or-expr ...)
|
||||
(raise-syntax-error #f "cut expects a a slot or an expression at the first position, given <...>" stx)]
|
||||
[(cut proc)
|
||||
#'(lambda () (proc))]
|
||||
[(cut <> slot-or-expr ... <...>)
|
||||
(generate-names/exprs #'(slot-or-expr ...)
|
||||
(lambda (slot-names names-or-exprs . ignored)
|
||||
#`(lambda (f . xs)
|
||||
#,(quasisyntax/loc stx
|
||||
(apply f #,@names-or-exprs xs)))))]
|
||||
[(cut <> slot-or-expr ...)
|
||||
(raise-syntax-error #f "cut expects an expression at the first position, given a slot <>" stx)]
|
||||
[(cut <...> slot-or-expr ...)
|
||||
(raise-syntax-error #f "cut expects an expression at the first position, given <...>" stx)]
|
||||
(generate-names/exprs #'(slot-or-expr ...)
|
||||
(lambda (slot-names names-or-exprs . ignored)
|
||||
#`(lambda (f)
|
||||
#,(quasisyntax/loc stx
|
||||
(f #,@names-or-exprs)))))]
|
||||
[(cut proc slot-or-expr ... <...>)
|
||||
;; Applying a wrong number of arguments to the the lamba generated by cut, will provoke an
|
||||
;; error caused by the application (proc ...). The quasisyntax/loc makes sure DrScheme
|
||||
|
@ -95,13 +103,23 @@
|
|||
[(cute)
|
||||
(raise-syntax-error #f "cute expects 1 or more slots or expressions, given none" stx)]
|
||||
[(cute <>)
|
||||
(raise-syntax-error #f "cute expects an expression at the first position, given a slot <>" stx)]
|
||||
[(cute proc)
|
||||
#'(lambda () (proc))]
|
||||
[(cute <> slot-or-expr ...)
|
||||
(raise-syntax-error #f "cute expects an expression at the first position, given a slot <>" stx)]
|
||||
#'(lambda (f) (f))]
|
||||
[(cute <...> slot-or-expr ...)
|
||||
(raise-syntax-error #f "cute expects an expression at the first position, given <...>" stx)]
|
||||
[(cute proc)
|
||||
#'(lambda () (proc))]
|
||||
[(cute <> slot-or-expr ... <...>)
|
||||
(generate-names/exprs #'(slot-or-expr ...)
|
||||
(lambda (slot-names ignored names bindings)
|
||||
#`(let #,bindings
|
||||
(lambda (f #,@slot-names . xs)
|
||||
(apply f #,@names xs)))))]
|
||||
[(cute <> slot-or-expr ...)
|
||||
(generate-names/exprs #'(slot-or-expr ...)
|
||||
(lambda (slot-names ignored names bindings)
|
||||
#`(let #,bindings
|
||||
(lambda (f #,@slot-names)
|
||||
(f #,@names)))))]
|
||||
[(cute proc slot-or-expr ... <...>)
|
||||
(generate-names/exprs #'(slot-or-expr ...)
|
||||
(lambda (slot-names ignored names bindings)
|
||||
|
@ -115,5 +133,3 @@
|
|||
(lambda #,slot-names
|
||||
(proc #,@names)))))]))
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user