Fork me on GitHub
#rdf
<
2020-11-20
>
Eric Scott03:11:58

Does anyone have any experience declaring builtin Jena extensions in Clojure?

(def always-true (proxy [BaseBuiltin Builtin] []
                   (getName [] "alwaysTrue")
                   (getArgLength [] 1)
                   (bodyCall [args length context]
                          ;; (throw (ex-info "asdf" {})) Whether this statement is included or not has no effect. (edit)
                         (def ^:dynamic *args* args)
                         (def ^:dynamic *context* context)
                     true)))
(.register BuiltinRegistry/theRegistry always-true)

Eric Scott03:11:24

I was hoping the code above would give me a little visibility into SWRL rules. It doesn't complain when I register it, but then when I insert alwaysTrue(?x) into the body of SWRL rule that already works, the code does not appear to be executed, i.e., the dynamic variables are not being bound. Am I missing something?

rickmoynihan11:11:06

@eric.d.scott: it’s not because you’re first raising an exception that’s somehow being swallowed is it? also pretty sure you can remove the ^:dynamic there. That just makes the vars support rebinding thread locally with binding. re def ing should work without for debugging purposes should work without that.

Eric Scott12:11:54

Oh. Yeah, I actually added the exception later just to see if I could shake something loose. Forgot to take that out of the example. But even without the exception this code shows no signs of being visited.

Eric Scott12:11:42

The puzzle here for me is why isn't this method being called? Are there missing metadata tags that are causing some other bodyCall method to be dispatched instead?

Eric Scott13:11:45

Ah. Nevermind. I'm an idiot. I was passing in a non-existent variable. Jeesh.