编译器优化对定义Common Lisp结构(或类)的影响是什么(如(defstruct person (age nil :type (or null integer))) vs (defstruct person (age -1 :type integer)) ? 我经常发现,使用第一种形式,使用表示特殊条件的空值非常方便; 例如,如果一个人的年龄不知道。 但在第二种形式中,您还可以使用ad-hoc指定的整数(如-1)来指示此情况。 一个表示优于另一个表示是否存在优势/劣势? (ps:在这种情况下,差异可能可以忽略不计,但似乎可能不适用于涉及哈希表等复杂对象的嵌套结构)
What is the potential impact on compiler optimization to defining a Common Lisp structure (or class) like (defstruct person (age nil :type (or null integer))) vs (defstruct person (age -1 :type integer))? I often find it convenient, using the first form, to have a null value signifying a special condition; for example, if a person's age is not known. But in the second form, you could also use an ad-hoc designated integer like -1 to indicate this condition. Is there an advantage/disadvantage to one representation over the other? (ps: In this case the difference is likely negligible, but seems like it might not be for nested structures involving complex objects like hash-tables, etc.)
更多推荐
发布评论