Point pair is a special kind of list
(setq a (cons 1 2))
Return (1 . 2)
(setq a (cons 2 nil))
Return (2)
(setq a (cons 1 '(2)))
Return (1 2)
The point pair (1 . 2) is in memory as follows:
D0 0C DF 0B 00 00 00 00 03 00 00 00 05 00 00 00
In a 32-bit system, it takes up 16 bytes
D0 0C DF 0b is a mark indicating that the data structure is a cons
00 00 00 00 reserved, function unknown
03 00 00 00 is an integer 1. The relationship between the value in memory and the integer value is 2n + 1, 1 becomes 3, 2 becomes 5 , 100 to 201
05 00 00 00 is an integer 2
'(2) this is a list with only one atom. It is in memory as follows:
D0 0C DF 0B 00 00 00 00 05 00 00 00 00 00 00 00
It can be regarded as a point pair (2 . Nil)
(setq a '(2 . Nil)) returns (2)
that list (2) and point pair (2 . Nil) are equivalent.
list '(1 2) occupies 32 bytes in memory, which uses twice as much memory space as (1 . 2)
D0 0C DF 0B 00 00 00 00 03 00 00 00 68 9A DF 0D
D0 0C DF 0B 00 00 00 00 05 00 00 00 00 00 00 00
list (1 2) can be regarded as a linked list composed of two point pairs
68 9A DF 0D is an address, which is the second atom of the first point pair and the address of the second point pair.
The return value of (setq a (cons 1 '(2 . Nil))) is table (1 2)
Similarly, the list (1 2 3) will occupy the memory space of three point pairs
明经网站www.mjtd.com又开始休假了,就发到这里吧

内存中的点对和表
点对是一种特殊的表
(setq a (cons 1 2))
返回 (1 . 2)
(setq a (cons 2 nil))
返回 (2)
(setq a (cons 1 '(2)))
返回 (1 2)
点对(1 . 2)在内存中是这样的:
D0 0C DF 0B 00 00 00 00 03 00 00 00 05 00 00 00
在32位系统中,它占用了16个字节
D0 0C DF 0B是一个记号,说明这数据结构是一个cons
00 00 00 00保留,功能未知
03 00 00 00是整数1,内存中的值和整数值的关系是2n+1,1变成3,2变成5,100变成201
05 00 00 00是整数 2
'(2)这是只有一个原子的表,它在内存中是这样:
D0 0C DF 0B 00 00 00 00 05 00 00 00 00 00 00 00
它可以看成是点对(2 . nil)
(setq a '(2 . nil)) 返回(2)
说明表(2)和点对(2 . nil)是等效的。
表'(1 2)在内存中占用了32个字节,它比(1 . 2)多用了一倍的内存空间
D0 0C DF 0B 00 00 00 00 03 00 00 00 68 9A DF 0D
D0 0C DF 0B 00 00 00 00 05 00 00 00 00 00 00 00
表(1 2)可以看成是两个点对组合成的链表
68 9A DF 0D 是个地址,它是第一个点对的第二个原子,也是第二个点对的地址。
(setq a (cons 1 '(2 . nil)))的返回值就是表(1 2)
同样道理,表(1 2 3)会占用3个点对的内存空间