为什么 Emacs 中的 fixnums 只有 29 位? [英] Why are fixnums in Emacs only 29 bits?

查看:20
本文介绍了为什么 Emacs 中的 fixnums 只有 29 位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

他们为什么不改变它?

之所以问是因为我是 emacs 的新手,我想将 Emacs 用作程序员计算器".所以,我可以操作 32 位 &64 位整数,并让它们像在本机机器上一样运行.

The reason ask is because I'm new to emacs and I would like to use Emacs as a "programmer calculator". So, I can manipulate 32-bit & 64-bit integers and have them behave as they would on the native machine.

推荐答案

Emacs-Lisp 是一种动态类型语言.这意味着您需要在运行时使用类型标签.如果您想处理数字,因此通常必须将它们打包到某种可以指向的标记容器中(即装箱"它们),因为在运行时无法区分指针和机器整数没有某种标记方案.

Emacs-Lisp is a dynamically-typed language. This means that you need type tags at runtime. If you wanted to work with numbers, you would therefore normally have to pack them into some kind of tagged container that you can point to (i.e. "box" them), as there is no way of distinguishing a pointer from a machine integer at runtime without some kind of tagging scheme.

出于效率原因,大多数 Lisp 实现因此不使用原始指针,而是我认为所谓的描述符.这些描述符通常是一个单独的机器字,可以表示一个指针、一个未装箱的数字(所谓的fixnum),或其他各种硬编码数据结构之一(通常值得编码 NIL 和 cons例如,特别是细胞).

For efficiency reasons, most Lisp implementations do therefore not use raw pointers but what I think is called descriptors. These descriptors are usually a single machine word that may represent a pointer, an unboxed number (a so-called fixnum), or one of various other hard-coded data structures (it's often worth encoding NIL and cons cells specially, too, for example).

现在,很明显,如果你添加类型标签,你就没有剩下完整的 32 位数字了,所以你只剩下 26 位,如 MIT Scheme 或 29 位,如 Emacs 或任何其他数字您没有用于标记的位.

Now, obviously, if you add the type tag, you don't have the full 32 bits left for the number, so you're left with 26 bits as in MIT Scheme or 29 bits as in Emacs or any other number of bits that you didn't use up for tagging.

各种动态语言的一些实现为 fixnums 保留了多个标签,以便它们可以为您提供 30 位甚至 31 位 fixnums.SBCL 是 Common Lisp 的一种实现,它这样做.不过,我不认为这对 Emacs 造成的复杂性是值得的.与文本编辑器中的 29 位 fixnum 算术相比,您多久需要一次快速的 30 位 fixnum 算术,它甚至不会将其 Lisp 代码编译成机器代码(或者是吗?我不需要)不记得了,实际上)?您是否正在使用 Emacs-Lisp 编写分布式.net 客户端?那么最好切换到 Common Lisp!;)

Some implementations of various dynamic languages reserve multiple tags for fixnums so that they can give you 30-bit or even 31-bit fixnums. SBCL is one implementation of Common Lisp that does this. I don't think the complication that this causes is worth it for Emacs, though. How often do you need fast 30-bit fixnum arithmetic as opposed to 29-bit fixnum arithmetic in a text editor that doesn't even compile its Lisp code into machine code (or does it? I don't remember, actually)? Are you writing a distributed.net client in Emacs-Lisp? Better switch to Common Lisp, then! ;)

这篇关于为什么 Emacs 中的 fixnums 只有 29 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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