Common Lisp中的原子和Clojure中的原子有什么区别? [英] What is the difference between an atom in Common Lisp and an atom in Clojure?

查看:162
本文介绍了Common Lisp中的原子和Clojure中的原子有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下页面介绍了原子在Clojure中的工作原理。它并没有说明关于Clojure中的原子和其他lisp方言之间的区别。

The following page talks about how atoms work in Clojure. It doesn't say a whole lot about the differences between atoms in Clojure and other lisp dialects.

Common Lisp中的原子和Clojure中的原子之间的主要区别是什么? (Clojure中原子的定义中缺少什么是存在于CL?)

What is the primary difference between an atom in Common Lisp and an atom in Clojure? (What is missing from the definition of atom in Clojure that exists in CL?)

推荐答案

在Clojure中的原子和Common Lisp (和大多数其他Lisps)是两个完全不相关的概念。他们与彼此无关,除了有相同的名字。

Atoms in Clojure and atoms in Common Lisp (and most other Lisps) are two completely unrelated concepts. They have nothing to do with each other, other than having the same name.

没有'差异'。它会问,在房子的窗口和计算机屏幕上的窗口之间的区别是什么?识别差异没有意义,因为这两个概念不相关。

There is no 'difference'. It would be asking what is the difference between a window in a house and a window on your computer screen? It does not make sense to identify differences, since the two concepts are not related.

在Clojure管理状态

'Atoms' in Clojure manage state.

'Atoms'在Lisp是一个单词的所有数据类型不cons单元格(如数字,字符,字符串,符号,...)。

'Atoms' in Lisp is a word for all data types that are not cons cells (like numbers, characters, strings, symbols, ...).

在Lisp中,函数 ATOM 简单定义为:

In Lisp the function ATOM is simply defined as:

(defun atom (object)
   (not (consp object)))



<有cons单元格,没有函数 consp ,不可能说(不是(consp对象))。因此,在Clojure中不存在像'atom'这样的Lisp概念。注意,Clojure有一个函数 cons ,但它不像Lisp中那样创建cons单元格。

Since Clojure does not have cons cells and no function consp, it is not possible to say (not (consp object)). Thus there does not exist a Lisp concept like 'atom' in Clojure. Note that Clojure has a function cons, but it does not create cons cells like in Lisp.

这篇关于Common Lisp中的原子和Clojure中的原子有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆