为什么尝试在Alexandria软件包中使用功能时,我会得到包裹锁定的错误?

发布于 2025-02-06 14:41:09 字数 362 浏览 1 评论 0原文

我不明白为什么这完全丢了错误。请解释为什么会以及如何清除这一意外的堵塞。谢谢。

CL-USER> (alexandria::starts-with-subseg "cat" "catdog")
; Debugger entered on #<PACKAGE-LOCKED-ERROR "interning ~A" {10059DE253}>

Lock on package ALEXANDRIA.1.0.0 violated when
interning STARTS-WITH-SUBSEG while in package COMMON-LISP-USER.

(编辑)刚刚意识到这是一个不良的函数名称。但是,我缺少什么?

I don't understand why this is throwing an error at all. Please explain why this would be and how I can clear this unexpected blockage. Thanks.

CL-USER> (alexandria::starts-with-subseg "cat" "catdog")
; Debugger entered on #<PACKAGE-LOCKED-ERROR "interning ~A" {10059DE253}>

Lock on package ALEXANDRIA.1.0.0 violated when
interning STARTS-WITH-SUBSEG while in package COMMON-LISP-USER.

(edit) just realized it's a bad function name. But still, what am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳哥哥 2025-02-13 14:41:09

亚历山大

The function ALEXANDIRA::BAD-FN-NAME is undefined.

(defpackage :alexandria
  (:nicknames :alexandria.1.0.0 :alexandria-1)
  (:use :cl)
  #+sb-package-locks
  (:lock t)
  …

如果


Restarts:
 0: [CONTINUE] Ignore the package lock.
 1: [IGNORE-ALL] Ignore all package locks in the context of this operation.
 2: [UNLOCK-PACKAGE] Unlock the package.
 3: [RETRY] Retry SLIME REPL evaluation request.
 4: [*ABORT] Return to SLIME's top level.
 5: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1007D29B63}>)

Alexandria现在,您将偶然发现“未定义功能”错误。

但是现在,返回您的替代,尝试自动完成错误的功能名称:&nbsp;实际上,这不是很好。当您调用功能,或者只是尝试使用LISP解释器评估符号时,您的LISP首先“实习生”(创建)此符号到相应的软件包中。它现在是“绑定”,除非您将其“解开”它,否则它将留在附近。

亚历山大开发人员采取了防御方法,这很好,因为亚历山大是CL生态系统的重要组成部分。您不想通过错误更改其绑定。想象一下,通过无意义……

(defun alexandria:starts-with-subseq () 
   :AHAHAH)

但是您不能,您会收到包锁的错误!谢谢你,亚历山大。

Lock on package ALEXANDRIA violated when
setting fdefinition of STARTS-WITH-SUBSEQ while in package CL-USER

您当然可以继续进行重新启动,但是您已经被警告了。


http://www.sbcl.org/manual/manual/#package-package-locks :调用功能时只需要1个冒号:alexandria:foo而不是::

If Alexandria hadn't put a package lock, you would see a more common error message:

The function ALEXANDIRA::BAD-FN-NAME is undefined.

But they put a lock:

(defpackage :alexandria
  (:nicknames :alexandria.1.0.0 :alexandria-1)
  (:use :cl)
  #+sb-package-locks
  (:lock t)
  …

Now you first saw this lock error, but look further and see the available restarts:


Restarts:
 0: [CONTINUE] Ignore the package lock.
 1: [IGNORE-ALL] Ignore all package locks in the context of this operation.
 2: [UNLOCK-PACKAGE] Unlock the package.
 3: [RETRY] Retry SLIME REPL evaluation request.
 4: [*ABORT] Return to SLIME's top level.
 5: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1007D29B63}>)

Choose the 0 to ignore the lock, and you'll now stumble on the "undefined function" error.

But now, go back to your REPL, and try to autocomplete the bad function name: you can O_o This is not so great, actually. When you call a function, or simply try to evaluate a symbol with the Lisp interpreter, your Lisp first "interns" (creates) this symbol into the corresponding package. It is now "bound" and it will stay around unless you "unbind" it with makunbound.

Alexandria developers took a defensive approach, and that's good because Alexandria is an important piece of the CL ecosystem. You don't want to change its bindings by error. Imagine doing, by inadvertance…

(defun alexandria:starts-with-subseq () 
   :AHAHAH)

But you can't, you get the package lock error! Thank you, Alexandria.

Lock on package ALEXANDRIA violated when
setting fdefinition of STARTS-WITH-SUBSEQ while in package CL-USER

you can of course carry on with the restart, but you've been warned.


http://www.sbcl.org/manual/#Package-Locks

ps: you only need 1 colon when calling a function: alexandria:foo and not ::.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文