Fork me on GitHub
#hyperfiddle
<
2023-01-29
>
didibus06:01:56

Seems RCF messes up with the &env of macros?

{i {:op :binding, :name i, :init {:op :invoke, :form (. clojure.lang.Numbers clojure.core/long_array 1 0), :env {:locals {}, :namespaces {}, :ns com.xadecimal.procedural}, :fn {:op :symbol, :local? false, :env {:locals {}, :namespaces {}, :ns com.xadecimal.procedural}, :form ., :ns nil, :name .}, :args [{:op :symbol, :local? false, :env {:locals {}, :namespaces {}, :ns com.xadecimal.procedural}, :form clojure.lang.Numbers, :ns nil, :name clojure.lang.Numbers} {:op :symbol, :local? false, :env {:locals {}, :namespaces {}, :ns com.xadecimal.procedural}, :form clojure.core/long_array, :ns clojure.core, :name long_array} {:op :const, :env {:locals {}, :namespaces {}, :ns com.xadecimal.procedural}, :form 1} {:op :const, :env {:locals {}, :namespaces {}, :ns com.xadecimal.procedural}, :form 0}], :children [:fn :args]}, :form i, :local :let, :children [:init]}}
I have a macro that uses &env, and I can't test it using RCF, because the macro no longer receives normal LocalBindings.

Geoffrey Gaillard09:01:31

RCF has its own analyzer, env and macroexpander. However, a userland macro should be called with a regular &env value. I'll create an issue.

Dustin Getz17:01:34

@U0K064KQV can I see your macro? I am considering possible solutions and want to understand better the pattern

didibus17:01:57

It's a non trivial macro. What I do is that I attach metadata to locals I create in one pass. And use the &env to inspect that metadata on another pass. I use that metadata to learn about the type hints and also to distinguish the locals my macro created versus the ones the user created.

didibus17:01:16

So &env is used to get all current locals, their primitive type, and their attached metadata.

👀 2