Marginally less opaque closures.
Specifically, a MistyClosure comprises an OpaqueClosure paired with the IRCode that defines it.
This is useful if you generate an OpaqueClosure, and want to be able to retrieve the IRCode later on.
# Get the `IRCode` associated with `sin(5.0)`.
ir = Base.code_ircode_by_type(Tuple{typeof(sin), Float64}) |> only |> first;
ir.argtypes[1] = Tuple{}
# Produce a `MistyClosure` using it. All kwargs are passed to the `OpaqueClosure`
# constructor.
mc = MistyClosure(ir; do_compile=true)
# Call it.
mc(5.0) == sin(5.0)Sometimes you'll already have an OpaqueClosure lying around, and not want to produce a new one from an IRCode (as this often takes a surprisingly large amount of time).
If this is the case, you can simply use the default constructor for MistyClosure.
That is, write
mc = MistyClosure(existing_opaque_closure, ir)Of course, it is your responsibility to ensure that ir and existing_opaque_closure are in agreement.