编译器优化结构或类定义(Compiler optimization of structure or class definitions)

编程入门 行业动态 更新时间:2024-10-27 00:35:01
编译器优化结构或类定义(Compiler optimization of structure or class definitions)

编译器优化对定义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.)

更多推荐

本文发布于:2023-08-07 20:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465927.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编译器   定义   结构   Compiler   definitions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!