gpt4 book ai didi

Clojure 控制台在简单的 HelloWorld 上发出 'unsigned-bit-shift-right' 警告

转载 作者:行者123 更新时间:2023-12-02 11:21:58 25 4
gpt4 key购买 nike

我今天正在使用 Clojure 迈出第一步,我立即遇到了第一个令人困惑的障碍!

我已经构建了一个新的 Leiningen(2.5.1) 项目,只想运行默认代码,即:

(ns wavescript.core
(:gen-class))

(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))

问题是 Lighttable(0.7.2) 控制台告诉:

WARNING: unsigned-bit-shift-right already refers to: #'clojure.core/unsigned-bit-shift-right in namespace: cljs.core, being replaced by: #'cljs.core/unsigned-bit-shift-right

我找到了一些 Google 条目,但没有一个能让我进一步了解。这是关于什么的?

最佳答案

这是由于在 clojure.core 命名空间以及 cljs.core 中发现符号 unsigned-bit-shift-right 引起的。 clojure.core 命名空间在 cljs.core 之前编译/加载,新符号的引入会引发警告。从 namespace 来看,您正在编写 clojurescript。如果你看这个文件cljs.core在第 2147 行,您将看到此表单:

(defn unsigned-bit-shift-right
"Bitwise shift right with zero fill"
[x n] (cljs.core/unsigned-bit-shift-right x n))

在 cljs.core 命名空间中。因此,显然,lighttable 正在导入 clojure.core 和 clj.core。

老实说,我什至不确定 cljs 实现是如何工作的,因为它完全是 self 引用的。此外,从第 451 行开始使用无符号位右移,没有前缀,因此它们必须使用 clojure.core 实现。奇怪的。上面的表格在前面所有的使用之后出现。看起来可以肯定地说该符号可以被安全地排除。事实上,这可能值得一个补丁......

要解决此问题,您可能需要尝试显式声明命名空间导入并排除该导入。 refer函数可以做到这一点。

因此,您将拥有一个如下所示的命名空间

(ns my.namespace.hello-world
[:require
[cljs.core :exclude [unsigned-bit-shift-right]]])

clojure.core 实现如下所示:

(defn unsigned-bit-shift-right
"Bitwise shift right, without sign-extension."
{:inline (fn [x n] `(. clojure.lang.Numbers (unsignedShiftRight ~x ~n)))
:added "1.6"}
[x n] (. clojure.lang.Numbers unsignedShiftRight x n))

或者,由于它们包装了功能,也许 cljs.core 被设计为不需要公开 clojure.core。如果是这种情况,请排除 clojure.core,然后看看您的代码是否能正常运行。

事实上,从 cljs.core 命名空间来看:

(ns cljs.core
(:refer-clojure :exclude [-> ->> .. amap and areduce alength aclone assert binding bound-fn case comment cond condp
declare definline definterface defmethod defmulti defn defn- defonce
defprotocol defrecord defstruct deftype delay destructure doseq dosync dotimes doto
extend-protocol extend-type fn for future gen-class gen-interface
if-let if-not import io! lazy-cat lazy-seq let letfn locking loop
memfn ns or proxy proxy-super pvalues refer-clojure reify sync time
when when-first when-let when-not while with-bindings with-in-str
with-loading-context with-local-vars with-open with-out-str with-precision with-redefs
satisfies? identical? true? false? number? nil? instance? symbol? keyword? string? str get
make-array vector list hash-map array-map hash-set

aget aset
+ - * / < <= > >= == zero? pos? neg? inc dec max min mod
byte char short int long float double
unchecked-byte unchecked-char unchecked-short unchecked-int
unchecked-long unchecked-float unchecked-double
unchecked-add unchecked-add-int unchecked-dec unchecked-dec-int
unchecked-divide unchecked-divide-int unchecked-inc unchecked-inc-int
unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int
unchecked-subtract unchecked-subtract-int unchecked-remainder-int
unsigned-bit-shift-right

bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set
bit-test bit-shift-left bit-shift-right bit-xor

cond-> cond->> as-> some-> some->>

if-some when-some test ns-interns var vswap!])

您可以看到 unsigned-bit-shift-right 应该从命名空间中排除。因此,您需要排除 clojure.core 来解决该问题。

关于Clojure 控制台在简单的 HelloWorld 上发出 'unsigned-bit-shift-right' 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28503950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com