9.0.0.3
6 Dynamic Require of Rhombus Exports
| (require rhombus/dynamic-require) | package: rhombus-lib |
The rhombus/dynamic-require module provides a function similar to Racket’s dynamic-require, but for accessing Rhombus module exports, potentially through dotted names.
procedure
(rhombus-dynamic-require mod name) → any/c
mod : module-path? name : (or/c symbol? (listof symbol?))
Although dynamic-require works for Rhombus exports that
correspond to plain variables, dynamic-require cannot get the
value of a Rhombus binding like the one constructor function default by
class, and it cannot access dotted paths that go through a
Rhombus namespace.
The rhombus-dynamic-require handles Rhombus bindings more generally. When name is a list, it access an export that corresponds to using the dot operator between the elements of the list.
Static access is normally better than dynamic access, so consider using rhombus-expression instead of rhombus-dynamic-require.
procedure
(rhombus-dynamic-require-predicate mod name) → (any/c . -> . boolean?) mod : module-path? name : (or/c symbol? (listof symbol?))
Rhombus modules typical export annotations intended to be used with
is_a instead of predicate functions. The
rhombus-dynamic-require-predicate function is like
rhombus-dynamic-require, but assuming that name refers
to an annotation, it produces a function that recognizes values that
satisfy the annotation.