0

我无法让 clojure从 core.logic 库中识别defrel 。因此,在使用 lein(和 compojure)设置项目并让 core.logic run*工作之后,我尝试了一个使用defrel的简单示例...下面是生成的标头,包括 :use clojure.core.logic 和失败(有关我想运行的完整示例,请参阅http://objectcommando.com/blog/2011/11/04/the-magical-island-of-kanren-core-logic-intro-part-1/ ) .

    (ns hw2.handler
      (:use compojure.core)
      (:refer-clojure :exclude [==])
      (:use clojure.core.logic)
      (:require [compojure.handler :as handler]
                [compojure.route :as route]))


    (defrel father Father Child)

lein 2.0生成的project.clj文件如下:

    (defproject hw2 "0.1.0-SNAPSHOT"
      :description "FIXME: write description"
      :url "http://example.com/FIXME"
      :dependencies [[org.clojure/clojure "1.5.1"]
                     [compojure "1.1.6"]
                     [org.clojure/core.logic "0.8.5"]
                    ]
      :plugins [[lein-ring "0.8.10"]]
      :ring {:handler hw2.handler/app}
      :profiles
      {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                            [ring-mock "0.1.5"]]}})

如果我运行 lein ring server 我得到:

    ian@U11-VirtualBox:~/cljtest/test1/hw2$ lein ring server
    Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: defrel in this context, compiling:(hw2/handler.clj:21:1)

根据 lein 的说法,一切都是最新的,即:lein deps 会相应地下载所有内容等。O/S 是 Ubuntu 13。

从命令行:

    ian@U11-VirtualBox:~/cljtest/test1/hw2$ lein repl
    nREPL se rver started on port 47146 on host 127.0.0.1
    REPL-y 0.3.0
    Clojure 1.5.1
        Docs: (doc function-name-here)
              (find-doc "part-of-name-here")
      Source: (source function-name-here)
     Javadoc: (javadoc java-object-or-class-here)
        Exit: Control+D or (exit) or (quit)
     Results: Stored in vars *1, *2, *3, an exception in *e

    user=> (use 'clojure.core.logic)
    WARNING: == already refers to: #'clojure.core/== in namespace: user, being replaced by: #'clojure.core.logic/==
    nil
    user=> (defrel father Father Child)

    CompilerException java.lang.RuntimeException: Unable to resolve symbol: defrel in this context, compiling:(/tmp/form-init6854269717866939932.clj:1:1) 

再次运行 * 工作正常。

我试过通过http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html但我不能找到任何有效的东西。

4

1 回答 1

3

变更日志

From 0.8.4 to 0.8.5
====

Changes
----
* old defrel functionality now replaced by pldb
于 2014-01-06T18:14:14.823 回答