better error

pull/10/head
Matthew Butterick 8 years ago
parent 6acea5ed3d
commit 8452fdfded

@ -1,4 +1,5 @@
#lang br #lang br
(require "line.rkt")
(provide b-expr b-sum b-product b-neg b-expt b-def b-func) (provide b-expr b-sum b-product b-neg b-expt b-def b-func)
(define (b-expr expr) (define (b-expr expr)
@ -28,7 +29,10 @@
#'(set! FUNC-ID (λ (VAR-ID ...) EXPR)))) #'(set! FUNC-ID (λ (VAR-ID ...) EXPR))))
(define-macro (b-func FUNC-ID ARG ...) (define-macro (b-func FUNC-ID ARG ...)
#'(let ([result (FUNC-ID ARG ...)]) #'(if (procedure? FUNC-ID)
(if (boolean? result) (let ([result (FUNC-ID ARG ...)])
(if result 1 0) (if (boolean? result)
result))) (if result 1 0)
result))
(raise-line-error
(format "undefined function: ~a" 'FUNC-ID))))

Loading…
Cancel
Save