Is there some code that already exists that finds free (logic, although perhaps that doesn’t really matter) in a quoted logic program?
(I’m writing some code that generates logic programs.)
that could be very challenging depending on how thorough you want it to be, have you considered including that information with the code you generate?
for arbitrary core.logic programs I think you would need to analyze arbitrary clojure forms for free variables (which tools.analyzer may have something you can use)
but since you control the generator, it isn't really arbitrary core.logic programs, so you can restrict the generator to a subset and only analyze the subset, and once you are tinkering with the generator, it may be easier to sort of build that information up in the generated programs vs analyzing the generated programs to recover it
Yeah; that’s the problem I ran into trying to do this as well
(the source query language is not core.logic; it compiles down to core.logic)
I ended up doing metadata annotation
(see first hunks of https://github.com/RackSec/desdemona/pull/111/files if you’re interested)
so it sounds like you have a source language, do a pass over that to turn it in to core.logic, then want to recover the free variable information from the core.logic program. I think the classic thing to do (compiler wise) would be to get that information in an analysis pass over the source language before compilation
hiredman: Yup. That’s exactly what I did :simple_smile:
hiredman: I was hoping to do it in a completely disjoint step so that the intermediary step doesn’t have to understand what a free variable is
but as you pointed out that way lies madness
(there’s one extra step: the source language is infix)