Fork me on GitHub
#core-logic
<
2016-03-25
>
lvh21:03:12

Is there some code that already exists that finds free (logic, although perhaps that doesn’t really matter) in a quoted logic program?

lvh21:03:25

(I’m writing some code that generates logic programs.)

hiredman22:03:47

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?

hiredman22:03:45

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)

hiredman22:03:14

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

lvh22:03:58

Yeah; that’s the problem I ran into trying to do this as well

lvh22:03:09

(the source query language is not core.logic; it compiles down to core.logic)

lvh22:03:14

I ended up doing metadata annotation

lvh22:03:26

(see first hunks of https://github.com/RackSec/desdemona/pull/111/files if you’re interested)

hiredman22:03:15

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

lvh22:03:50

hiredman: Yup. That’s exactly what I did simple_smile

lvh22:03:10

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

lvh22:03:18

but as you pointed out that way lies madness

lvh22:03:41

(there’s one extra step: the source language is infix)