reify
The reify macro lets you create an anonymous instance of a datatype that implements either a protocol or an interface. Note that you get access by closure, not by declaration. This is because there are no declared members.
(reify & opts+specs) |
reify, like deftype and defrecord, takes the name of one or more protocols, or interfaces, and a series of method bodies. Unlike deftype and defrecord, it doesn’t take a name or a vector of fields; datatype instances produced with reify don’t have explicit fields, relying instead on closures.
Let’s compose some John Cage--style[52] aleatoric music[53] or, better yet, create an aleatoric music generator. We’ll use reify to create an instance of a MidiNote that will play a different random note ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access