之前学 elisp 的时候一直感觉思维转不过来很纠结,看了 The Nature of
Lisp,原来正如 Code
Complete - Laying the Foundation
章节讲的那样,我们认识新事物总是会借鉴思维里面已有的 Metaphor, 我只用过 C,
C++, Java,Python, Objective-C, 也就意味着我基本只有这些语言的
metaphor,都跟 Lisp
差异很大,也难怪了。但也正因为如此,才需要不断的克服自身的排斥心理,去接触更多的新事物。
正如书中所云:
A software metaphor is more like a searchlight than a road map. It
doesn’t tell you where to find the answer, it tells you how to look for
it. A metaphor serves more as a heuristic than it does as an
algorithm.
为了节省内存使用,使用 union
结构,这个设计很巧妙,每一个元素(内存区域对象)即可以当作下一个元素的指针,例如后面代码中的
result -> _M_free_list_link,也可以当作该元素的值,例如
*__my_free_list。整个 free lists
的结构便是一串使用后者的元素构成的节点,每个节点的值是使用前者构成的单向链表的首地址。