- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
据我所知,Lisp 语法表示 AST,但采用高级格式以允许人类轻松阅读和修改,同时也便于机器处理源代码。
因此,在 Lisp 中,代码是数据,数据是代码,因为代码 (s-epxression) 本质上只是 AST。我们可以将更多 AST(这是我们的数据,只是 lisp 代码)插入其他 AST(lisp 代码)或独立地扩展其功能并在运行时(运行时)对其进行操作,而无需重新编译整个操作系统以集成新的代码。在其他语言中,我们必须重新编译才能将人类语言源代码转换为有效的 AST,然后再编译成代码。
这是否是 Lisp 语法最初设计的原因(代表 AST 但人类可读,以满足人类和机器)?为了在人机之间实现更强大(即时 - 运行时)以及更简单(无需重新编译,更快)的通信?
我听说 Lisp 机器只有一个地址空间来保存所有数据。在Linux这样的操作系统中,程序员只有虚拟地址空间,并假装是真实的物理地址空间,可以为所欲为。 Linux 中的数据和代码是分开的区域,因为实际上,数据就是数据,数据就是代码。在用 C(或类 C 语言)编写的普通操作系统中,如果我们只为整个系统操作一个地址空间,并且将数据与代码混合在一起,那将是非常困惑的。
在 Lisp Machine 中,既然代码就是数据,数据就是代码,这就是它只有一个地址空间(没有虚拟层)的原因吗?既然我们有 GC 而没有指针,那么在不破坏物理内存的情况下操裁剪理内存是否安全(因为只有 1 个空间要简单得多)?
编辑: 我问这个是因为据说 one of the advantage Lisp 的是单地址空间:
A safe language means a reliable environment without the need to separate tasks out into their own separate memory spaces.
The "clearly separated process" model characteristic of Unix has potent merits when dealing with software that might be unreliable to the point of being unsafe, as is the case with code written in C or C++ , where an invalid pointer access can "take down the system." MS-DOS and its heirs are very unreliable in that sense, where just about any program bug can take the whole system down; "Blue Screen of Death" and the likes.
If the whole system is constructed and coded in Lisp, the system is as reliable as the Lisp environment. Typically this is quite safe, as once you get to the standards-compliant layers, they are quite reliable, and don't offer direct pointer access that would allow the system to self-destruct.
Third Law of Sane Personal Computing
Volatile storage devices (i.e. RAM) shall serve exclusively as read/write cache for non-volatile storage devices. From the perspective of all software except for the operating system, the machine must present a single address space which can be considered non-volatile. No computer system obeys this law which takes longer to fully recover its state from a disruption of its power source than an electric lamp would.
如前所述,单个地址空间将所有正在运行的进程保存在同一内存空间中。我很好奇为什么人们坚持认为单一地址空间更好。我将它与 Lisp 的类 AST 语法联系起来,试图解释它如何适合单空间模型。
最佳答案
您的问题并没有非常准确地反射(reflect)现实,尤其是在 Linux 和其他操作系统中有关代码/数据分离的部分。实际上,这种分离不是在操作系统级别强制执行的,而是由编译器/程序加载器强制执行的。在操作系统级别,只有内存页面可以设置不同的保护位(如可执行、只读等),在这个级别之上存在不同的可执行格式(如 Linux 中的 ELF),它们指定对程序内存不同部分的限制。
回到 Lisp,据我所知,历史上,Lisp 的创建者使用 S-expression 格式,因为他们想专注于语言的语义,将语法搁置一段时间。有一个计划最终为 Lisp 创建一些语法(参见 M 表达式),并且有一些基于 Lisp 的语言有更多的语法,比如 Dylan。但是,总的来说,Lisp 社区已经达成共识,即 S 表达式的好处超过了它们的缺点,因此他们坚持了下来。
关于代码作为数据,这并不严格绑定(bind)到S表达式,因为其他代码也可以被视为数据。整个方法称为元编程,许多语言在不同级别和不同机制上支持它。每一种支持 eval
的语言(Perl、JavaScript、Python)都允许将代码视为数据,只是表示几乎总是一个字符串,而在 Lisp 中它是一棵树,这要方便得多并促进高级的东西,比如宏。
关于lisp - Lisp 语法对 AST 建模的目的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11322922/
我正致力于通过 OAuth 合并外部 API,但对 expires_in 属性的用途有点迷惑。通过阅读,应该对 api token 的使用进行防御性编码,因为您应该预料到 token 在任何时候都可能
有人可以概述或总结一下 Spring 框架上下文中 bean 的用途吗? 我了解标准的 Java bean(没有 arg 构造函数、getter/setter,通常是序列化的),但 Spring be
使用 OpenGL 4.1 和 ARB_separate_shader_objects,我们能够在着色器程序中存储着色管道的不同阶段。众所周知,要使用这些,我们需要将它们附加到程序管道对象,然后绑定(
正如我从文档中了解到的那样,“MoveIteratorFactory”的目的是生成每一步都需要执行的 Action 。 “getSize”方法的移动子集有多大? “createOriginalMove
请解释 CMakeLists.txt 中这一行的目的是什么: 包括(InstallRequiredSystemLibraries) 我在 CMake 示例中看到这一行,但找不到好的解释,为什么我需要它
这里是新手。我仍在尝试理解在多个布局中运行单个进程或目的的概念。 例如,我想在我的申请中添加“提交后”功能。有一个包含标题、内容等文本框的主布局,以及一个链接到另一个布局以选择类别的按钮。我的问题是,
我在看 Box Oauth2.0 View Controller : https://github.com/box/box-ios-sdk-v2/blob/master/BoxSDK/OAuth2/B
我编写了一个将字符串复制到系统剪贴板的 Java 应用程序。构造函数使用 Clipboard.setContents(Transferable contents, ClipboardOwner own
阅读此文后:http://sourcemaking.com/design_patterns/command 我还是不太明白为什么我们需要这个。 最佳答案 想法是,如果命令被封装为对象,那么这些命令可以
我知道 c++ 中的模板是做什么的,但是今天我看到了一些奇怪的代码: template <> void swap(foo &a, foo &b) { a.name = b.name; a.
我不太明白 C# Collections 中 IEnumerator 的用途是什么。它的用途是什么,为什么要使用它? 我试着在线查看 http://msdn.microsoft.com/en-us/l
不幸的是,我今天做了一些代码考古(同时重构了一些旧的危险代码)并发现了这样的小化石: # line 7 "foo.y" 能在里面找到如此古老的宝藏,我完全惊呆了。我在 C 编程的网站上阅读了它。然而,
您能否澄清一下此注释的实际用途? - 如果我们没有使用数据库中的 SQL 表定义定义相应的约束,会发生什么情况。当我们尝试插入时,hibernate 会检查唯一性吗?或者这就是DB的目的吗?如果 hi
我在视频教程中看到过这段代码: const navToggle = ["Menu"].join(""); $(".site-header").prepend(navToggle); 我明白它的基本作用
我想知道这个成员函数的 scroll_to(TextBuffer::iterator& iter, double within_margin = 0)参数 within_margin。 API 是这样
我想知道是否可以将子目录提交到目录例如,假设您有 site.com/directory 可以将子目录提交到目录。我即将开始为希望她的网站在搜索引擎中排名靠前的客户进行一些搜索引擎优化。我知道实现此目的
STL 迭代器的用途是什么?为什么程序员要创造这个概念? 最佳答案 迭代器允许您将算法与容器分开。只要您有开始和结束迭代器,并且知道迭代器的功能(随机访问等),您就可以在迭代器指定的范围内进行操作。例
NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&respons
我正在编写代码,使用通用的 linux i2c 驱动程序 linux/i2c-dev.h 实现一个简单的 i2c 读/写功能 我对 ioctl 感到困惑:I2C_SLAVE 内核文档说明如下: You
在尝试克隆可变集合时,我最初的方法是对 mutable.Cloneable 特征使用 clone() 方法。但是,这取决于创建引用副本的 java.Object.clone 实现,而不是深拷贝。通过测
我是一名优秀的程序员,十分优秀!