【问题标题】:Unable to resolve symbol: defrel in this context无法解析符号:此上下文中的 defrel
【发布时间】:2014-01-07 02:14:14
【问题描述】:

我无法让 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 工作,但找不到任何可行的方法。

【问题讨论】:

    标签: clojure clojure-core.logic


    【解决方案1】:

    Changelog

    From 0.8.4 to 0.8.5
    ====
    
    Changes
    ----
    * old defrel functionality now replaced by pldb
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-18
    • 1970-01-01
    • 2014-02-05
    • 2016-12-31
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多