- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想知道如何区分'value' 和'expression'。
In computer science, a value is an expression which cannot be evaluated any further (a normal form).[1] The members of a type are the values of that type.[1] For example, the expression 1 + 2 is not a value as it can be reduced to the expression 3. This expression cannot be reduced any further (and is a member of the type Nat) and therefore is a value.
我从下面的 url 中找到了上面的声明: https://en.wikipedia.org/wiki/Value_(computer_science) 2
从这句话中我觉得:
I think "value" look like the "atom" in chemistry based upon the definition of Mitchell, John C.
但有人否认了这一点:
But, even expressions can be (represented as) values. The classic case being an s-expression in Lisp-like languages. – user2864740
这个演讲在另一个线程中:what-is-the-value-in-1st-class-value 3
如果user2864740什么都不说,事情就这么简单了。但他这么说,我很困惑。
有人可以向我解释一下这种情况吗?还是类似 lisp 的语言中可能存在的差异?
提前致谢!
[1] 约翰·C·米切尔 (1996)。编程语言基础。麻省理工学院出版社。
最佳答案
如果您不了解 Lisp,请阅读 SICP玩一些Scheme实现。
(经典的 SICP 书籍是必读的 - 它是一本非常好的编程入门书籍 - 因此,即使您了解 Lisp 但没有读过 SICP,您也确实应该阅读它;而且它是免费提供的在线。)
我强烈推荐阅读 C.Queinnec 的 Lisp In Small Pieces这本书解释了 LISP 解释器或编译器表达式是如何设计的,因此涵盖您的问题非常详细。
(实际上你的问题需要一整本书来回答,Queinnec 的书就是那本书)
LISP 是一个 homoiconic语言,因此 s-expressions是值(但有几个值不是表达式,特别是 closures )。但大多数编程语言——C、Ocaml、Javascript、C++、Java 等——(遗憾的是)不是谐音:它们的 AST 不是一个值,表达式不能本地操作AST。
顺便说一句,维基百科的句子
a value is an expression which cannot be evaluated any further
并不总是正确的。例如,对于 C 语言,值和表达式是不同种类的野兽。
您还应该阅读有关 formal semantics 的内容的编程语言。
此外,阅读 Scott 的 Programming Language Pragmatics会给你一个更广阔的视野(通过几种编程语言)。
关于lisp - 想要区分值(value)和表达,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34647121/
使用登录后,我想吐出用户名。 但是,当我尝试单击登录按钮时, 它给了我力量。 我看着logcat,但是什么也没显示。 这种编码是在说。 它将根据我在登录屏幕中输入的名称来烘烤用户名。 不会有任何密码。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a min
我是一名优秀的程序员,十分优秀!