Is it possible to use the JavaScript operators typeof
or delete
via interop with CLJS?
Not via interop. But you can use js-delete
and goog/typeOf
.
@p-himik Thank you!
Is there a way to make this work in CLJS?
cljs.user=> (let [x IDeref] (satisfies? x (atom 0)))
false
whoops, wrong channel. 😬
reading the source of the satisfies?
macro, it looks like it relies on using the analyzer to get the name of the protocol so that it knows what attribute to look up on the object being checked
in order to change this, I think you would have to emit the name of the protocol in code somewhere where you could read it at runtime
yeah, I worked around this by using cond = on the protocol object and then hardcoding the satisfies...
I think that's your best bet
emitting the name in code and trying to use it at runtime, would break advanced optimizations where the attribute on the object gets renamed. emitting the check via a macro ensures that the check stays coherent after optimization
we could tell GCC not to optimize protocols but I don't think we want that 🙂