Document how defn/implicit do with multiple goals does not work
Description
Environment
Clojure 1.8
core.logic 0.8.10
Attachments
1
logic-repl.txt
05 Aug, 2016
Activity

Oskar Wickström August 5, 2016 at 1:48 PM
Oskar Wickström
August 5, 2016 at 1:48 PM
Oh, I just found `all` (http://clojuredocs.org/clojure.core.logic/all) which seems to be preferred over `(fresh [] ...)`.

Oskar Wickström August 5, 2016 at 12:03 PM
Oskar Wickström
August 5, 2016 at 12:03 PM
The REPL session got messed up, now attached as a file instead.
Details
Details
Assignee
Reporter

Labels
Priority
Created August 5, 2016 at 12:01 PM
Updated August 5, 2016 at 1:48 PM
Hi! I have a small documentation improvement proposal:
When using regular `defn` to create a relation, I've found that an empty
(fresh [] ...)
is needed if you want to use multiple relations and goals inside your defn:ed relation, otherwise your goals are in the implicit do from defn, and only the last one has any effect.Simple example:
{{
defn-logic> (defn test [a b]
(== a 1)
(== b 2))
#'defn-logic/test
defn-logic> (run* [q] (fresh [a b]
(== q [a b])
(test a b)))
([_0 2])
defn-logic> (defn test [a b]
(fresh []
(== a 1)
(== b 2)))
#'defn-logic/test
defn-logic> (run* [q] (fresh [a b]
(== q [a b])
(test a b)))
([1 2])
defn-logic>
}}
Again, this is perfectly correct and reasonable, but maybe a bit confusing for beginners, in that the implicit do "fails silently". What I'm looking for here is probably just a heads up in the Wiki docs. I couldn't find it, but maybe it exists already? I'd be happy to add it to the documentation and send a PR.