什么是不正确的清单? [英] What are improper lists for?

查看:50
本文介绍了什么是不正确的清单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我先前的问题的后续内容:为什么我们需要零?显然,大多数时候都使用适当的列表.但是,列表不正确的目的是什么?

This is a follow-up of my previous question: Why do we need nil? Clearly, proper lists are used most of the time. But what is the purpose of an improper list?

推荐答案

没有充分的理由.不正确的列表真正有好处的唯一一件事就是作为关联列表的语法的一部分,即使在那儿,自定义键-值对的语法也会更好.记录类型可以更好地实现您可以想到的用于不正确列表的所有方法,毕竟,记录类型是包含列表的:您可以根据记录定义Lisp列表,但不能相反(因为列表不允许您定义类型与该语言中所有其他类型都不相交的数据结构.

For no good reason. The only thing that improper lists are truly good for is as part of the syntax for association lists—and even there, a custom syntax for key-value pairs would be better. Any use you can think of for improper lists can be better implemented with record types—which, after all, subsume lists: you can define Lisp lists in terms of records, but not the other way around (because lists don't allow you define data structures whose type is disjoint from all other types in the language).

滥用成对和列表来表示所有类型的数据就是我所说的 Lisp程序员病,这是许多Lisp拥护者提倡的一种真正的耻辱.我不得不清理这些东西太多次了.

The abuse of pairs and lists to represent all types of data is what I like to call Lisp programmer's disease, and it's a real shame that so many Lisp advocates advocate for it. I've had to clean up that stuff way too many times.

这篇关于什么是不正确的清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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