forked from jeapostrophe/racket-langserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic-import.rkt
More file actions
21 lines (17 loc) · 756 Bytes
/
dynamic-import.rkt
File metadata and controls
21 lines (17 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#lang racket/base
(provide dynamic-imports)
(define-syntax-rule (import-once mod name fail-thunk)
(define name
(let ([logging-fail-thunk (λ ()
(log-info "symbol '~a' from module '~a' fail to load." 'name mod)
(fail-thunk))])
(with-handlers ([exn:fail? (λ (_e)
(logging-fail-thunk)
(void))])
(dynamic-require mod 'name logging-fail-thunk)))))
(define-syntax-rule (dynamic-import-mod mod names ... fail-thunk)
(begin
(import-once mod names fail-thunk) ...))
(define-syntax-rule (dynamic-imports (mod names ...) ... fail-thunk)
(begin
(dynamic-import-mod mod names ... fail-thunk) ...))