From 87e5c349350547cc1c198e763e9ce6a8df92018f Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Thu, 11 Dec 2008 21:05:03 +0000 Subject: [PATCH] use !defined for either syntax or simple binding, add !bound for a binding that cannot be a syntax svn: r12781 --- collects/handin-server/checker.ss | 14 ++++++++++++++ collects/handin-server/scribblings/checker.scrbl | 14 +++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/collects/handin-server/checker.ss b/collects/handin-server/checker.ss index cff230911c..8d7e7e2b0c 100644 --- a/collects/handin-server/checker.ss +++ b/collects/handin-server/checker.ss @@ -655,8 +655,21 @@ (define (get-namespace evaluator) (call-in-sandbox-context evaluator (lambda () (current-namespace)))) +;; checks that ids are defined, either as variables or syntaxes (provide !defined) (define-syntax-rule (!defined id ...) + ;; expected to be used only with identifiers + (begin (with-handlers ([exn:fail:contract:variable? + (lambda (_) + (error* "missing binding: ~e" (->disp 'id)))] + [exn:fail:syntax? void]) + (parameterize ([current-namespace (get-namespace (submission-eval))]) + (namespace-variable-value `id))) + ...)) + +;; checks that ids are defined as variables, not syntaxes +(provide !bound) +(define-syntax-rule (!bound id ...) ;; expected to be used only with identifiers (begin (with-handlers ([exn:fail:contract:variable? (lambda (_) @@ -669,6 +682,7 @@ (namespace-variable-value `id))) ...)) +;; checks that ids are defined as syntaxes, not variables (provide !syntax) (define-syntax-rule (!syntax id ...) ;; expected to be used only with identifiers diff --git a/collects/handin-server/scribblings/checker.scrbl b/collects/handin-server/scribblings/checker.scrbl index 2d732ef102..7eb714f4d2 100644 --- a/collects/handin-server/scribblings/checker.scrbl +++ b/collects/handin-server/scribblings/checker.scrbl @@ -327,16 +327,20 @@ code.} @defform[(!defined id ...)]{ Checks that the given identifiers are defined in the (evaluated) - submission, and throws an error otherwise.} + submission, and throws an error otherwise. The identifiers can be + bound as either a plain value or as a syntax.} -@defform[(!procedure id arity)]{ - - Checks that @scheme[id] is defined, and is bound to a procedure.} +@defform[(!bound id ...)]{ + Checks that the given identifiers are defined in the (evaluated) + submission as a plain value. Throws an error if not, or if an + identifier is bound to a syntax.} @defform[(!syntax id arity)]{ - Checks that @scheme[id] is defined, and is bound as a macro.} +@defform[(!procedure id arity)]{ + Checks that @scheme[id] is defined, and is bound to a procedure.} + @defform[(!procedure* expr arity)]{ Similar to @scheme[!procedure] but omits the defined check, making