core-logic

lvh 2016-03-25T21:30:12.000005Z

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

lvh 2016-03-25T21:30:25.000006Z

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

2016-03-25T22:27:47.000007Z

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?

2016-03-25T22:28:45.000008Z

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)

2016-03-25T22:30:14.000009Z

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

lvh 2016-03-25T22:33:58.000010Z

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

lvh 2016-03-25T22:34:09.000011Z

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

lvh 2016-03-25T22:34:14.000012Z

I ended up doing metadata annotation

lvh 2016-03-25T22:34:26.000013Z

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

2016-03-25T22:37:15.000015Z

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

lvh 2016-03-25T22:37:50.000016Z

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

lvh 2016-03-25T22:38:10.000017Z

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

lvh 2016-03-25T22:38:18.000018Z

but as you pointed out that way lies madness

lvh 2016-03-25T22:39:41.000019Z

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