Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Racket exn:fail? unbound

I've been using the following language definition file, eopl-printing.rkt,

#lang racket
    (require (except-in eopl #%module-begin))
    (provide (all-from-out eopl))
    (provide #%module-begin)
as suggested in DrRacket EOPL Scheme output. All has being going well, except when I try to invoke an exn function as in:
#lang s-exp "eopl-printing.rkt"
(require rackunit)
(check-exn
   exn:fail?
   (lambda ()
     (error 'hi "there")))

Instead of the test passing successfully as expected, I get a "exn:fail?: unbound identifier ..." message. I've read the documentation on modules and tried various ways to try to re-expose the Racket exn definitions but without any luck. Any suggestions?

like image 565
Tom Koenig Avatar asked Jun 01 '26 07:06

Tom Koenig


1 Answers

The eopl-printing.rkt file defines a language that only includes the bindings from the eopl library plus #%module-begin from racket but nothing else.

But you can still easily import racket bindings in any file written in the eopl-printing.rkt language:

#lang s-exp "eopl-printing.rkt"
(require rackunit)
(require racket)
(check-exn
   exn:fail?
   (lambda ()
     (error 'hi "there")))

Alternatively, you can have your eopl-printing.rkt language provide the additional racket forms that you want:

#lang racket
(require (except-in eopl #%module-begin))
(provide (all-from-out eopl))
(provide #%module-begin exn:fail? error)

Or just re-provide everything in racket:

#lang racket
(require (except-in eopl #%module-begin))
(provide (all-from-out eopl))
(provide (all-from-out racket))
like image 58
stchang Avatar answered Jun 03 '26 21:06

stchang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!