> On Aug 11, 2018, at 9:00 AM, Sage Gerard <zyrolast...@gmail.com> wrote:
> 
> I'm starting to think writing these kind of exercises in a friendly way is 
> only possible with macros, but before I go that far, is it possible for me to 
> catch a module-level unbound identifier error and print a rackunit failure 
> outright without distracting the student?
> 
> I'd appreciate feedback on the design here too, since I have to pick a 
> direction to handle this kind of problem project-wide.

Perhaps consider making a little `racket/koan` language for your exercises that 
includes some extra conveniences. For instance, one way to address your unbound 
identifiers is to redefine `#%top` as shown below. But you could move that into 
`racket/koan`.


#lang racket/base

(require rackunit)

(require (for-syntax racket/base))
(define-syntax (#%top stx)
  (syntax-case stx ()
    [(_ . id) (not (identifier-binding #'id)) #'(λ _ (format "unbound 
identifier: ~a" 'id))]
    [(_ . id) #'id]))

;; Produce a single struct that passes all assertions.
(let ([p "?"])
  (check-pred racketeer? p)
  (check-pred programmer? p)
  (check-pred struct? p)
  (check-pred procedure? set-programmer-salary!)
  (check-equal? (programmer-confusion-level p) 10)
  (check-equal? (racketeer-desire-for-racket-jobs p) 9001))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to