- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在 CppCon 演讲中(https://www.youtube.com/watch?v=80BZxujhY38 在 5:00)Herb Sutter 暗示 defun defun 3
在某种程度上是个问题。后我用谷歌搜索,我仍然不清楚为什么。有人可以详细说明吗?
最佳答案
在 comment from the same video 中:
Herb Sutter
See also the paper, P0707 (http://wg21.link/p0707), and search for "defun." Lisp defun (and Scheme define) lets you define a function... but in Lisp and Scheme you can even redefine built-in functions and macros, including defun/define itself which is what "defun defun" / "define define" does. Here's a sample related StackExchange question: https://emacs.stackexchange.com/questions/375/symbols-value-as-a-variable-is-void-defun-when-reloading-emacs .
I'm not interested in doing anything like that in C++, and there's nothing like that in my proposal, you can't change any definitions (including of this class after it is defined), you can't reach out and affect anyone else's type or code, the only thing you can do is participate in generating the one-time-and-then-immutable definition of this class you're writing right now which is nice and localized and bounded... and still very powerful.
linked paper包含此部分:
5.2.1 Problems in other languages
In Lisp and related languages, programmers can redefine other people’s code and even global language facilities (e.g., the notorious
(defun defun () 3)
in Lisp, or(define define () 3)
in Scheme). This is powerful, but undisciplined (causes arbitrary global effects up to and including breaking the language itself), fragile (Lisp makes it notoriously easy to write “write-only” code that is difficult to review, read, and maintain), and causes programs to be tightly coupled among their components and with their developer’s environment (Lisp makes it notoriously easy to write code whose meaning depends on local customizations, is hard to share, and when shared is hard to compose with other code that came from an environment with competing assumptions).4
脚注说:
4 Various incarnations and offshoots of Lisp attempted to mitigate this problem in various ways without actually taking away the root cause: Common Lisp added the guarantee that all symbols in the package
COMMON-LISP
are protected and must not be redefined by user code otherwise you get undefined behavior; although this provides some protection for the standard facilities, it does not solve the general problem because it still permits one set of user code to redefine things in another set of user code. Also, implementations like SBCL attempted to further improve the problem by providing ways to “lock” packages so their contents cannot be accidentally redefined; however, even SBCL also provides ways to “unlock” them again.
关于lisp - (defun defun () 3) 会做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56817883/
在 CppCon 演讲中(https://www.youtube.com/watch?v=80BZxujhY38 在 5:00)Herb Sutter 暗示 defun defun 3 在某种程度上是
比如我把函数名传给另一个函数 (personal-function 'func-name '(attr1 attr2 ...)) 我想做的是 (defun personal-function (fun
我正在尝试动态查找当前运行的函数(此函数)的名称,即 (defun my-func () (remove-hook 'some-hook this-function) (do-
当将遗留代码从 clisp 移植到 sbcl 时,我遇到了引发问题的语法,该代码在 clisp 中运行时没有明显错误: (defun foo ((alpha integer)) (princ (t
我想从我正在创建的包中定义一个名为“defun”的宏,我想将它导出以在某些地方使用。有一个名为 parenscript 的库可以在它的包中执行此操作,如下所示, (export #:defun) 当我
我正在尝试将 Lisp 作为我的新语言,但我遇到了一些问题,无法弄清楚如何让函数的一部分处理传递给它的列表的每个元素。 为了学习如何解决这个问题,我正在尝试编写一种相当基本的除法形式,当列表中的一个元
对不起,这是一个非常新手的 Common Lisp 问题。 我正在学习 common-lisp 和包系统。 我从 http://cl-cookbook.sourceforge.net/packages
我正在尝试学习 lisp 并搜索了问题并找到了我无法理解的答案。有人可以帮助我解决我正在尝试的问题。 所以我创建了一个基本函数 RotateL,它应该将列表作为其参数并返回一个新列表,其中前一个元素变
我需要以编程方式调用类似于 defun 的宏,以便定义给定(自动生成)名称的函数。我的尝试是这样的: `(defun ,(intern "autogen-command-33") () (echo "
是否可以使用具有附加可选参数的代码“r”编写交互式 defun(以便它在选定区域内执行操作,但使用另一个参数)?我想要以下内容: (defun my-function (start end &opti
我想要一个函数以交互方式提示输入现有目录,但不是从默认目录开始,我想要一个函数本地默认路径,如 '~/should/start/here/always/in/this/function' 开始于使用时
我在 tensorflow 中使用 Defun 装饰器时遇到问题。也就是说,Defun 不能关闭任何外部创建的 TF 操作。下面是一个独立的例子,展示了我想做的事情。请注意,张量 x 属于对 cust
如果我这样做 (add-hook 'haskell-mode-hook (lambda () (setq indent-tabs-mode t) (setq t
在编译源代码的过程中,我希望 GNU Make 调用一个 emacs defun。为此,我有 2 个选择: 启动一个新的 emacs 实例,加载所需的函数并调用它。 像这样从 emacsclient
2013 年 5 月更新:从 GNU Emacs 24.3.1 开始,(let .. (defun..)) 字节编译正常,没有警告,字节编译代码与未编译代码的工作方式相同。只是不要忘记将文件变量 le
所以我可以这样做: (defparameter *some-function* ... ; 稍后返回 lambda 或者这个: (defun some-function ... 无论是哪种,我都可以使
取这个函数: (defun sum-greater (x y z) (> (+ x y) z)) 据我了解,在 LISP 中,列表中的第一个元素始终表示要对后续原子/列表执行的函数。那么,为什么 L
我正在 CL 中尝试一些基本的东西,但不明白为什么这不会编译: (defun ifelse (the-test) (cond ((the-test) (format t "passed test"
这个问题在这里已经有了答案: Common lisp error: "should be lambda expression" (4 个答案) 关闭 5 年前。 我正在尝试制作一个将中缀输入更改为前
这个问题在这里已经有了答案: Common lisp error: "should be lambda expression" (4 个答案) 关闭 5 年前。 我正在尝试制作一个将中缀输入更改为前
我是一名优秀的程序员,十分优秀!