Clojure文档“关联支持”是什么意思? [英] What do the Clojure docs mean by "associative support"?

查看:60
本文介绍了Clojure文档“关联支持”是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Clojure 有关数据类型的文档。在 deftype defrecord 之间的差异列表下,它指出 defrecord 具有关联支持。我是Clojure的新手,我想知道是否有人可以为我澄清这个术语。

I was reading the Clojure documentation on datatypes. Under the list of differences between deftype and defrecord it states that defrecord has "associative support". I'm new to Clojure and was wondering if anyone could clarify this term for me.

推荐答案

关联支持表示对象实现关联界面。这包括按键查找,以及创建具有附加键/值对的新对象的功能。

"Associative support" means that an object implements the Associative interface. This includes lookup by key, and the ability to create a new object with an additional key/value pair added.

通常,这意味着由<$ c创建的对象$ c> defrecord 在很大程度上可以被视为标准的Clojure映射,而在使用 deftype 时,想要该功能,您需要自己实现。

In general, this means that objects created by defrecord can be -- for the large part -- treated as if they were standard Clojure maps, whereas when using deftype, if you want that functionality you need to implement it yourself.

这篇关于Clojure文档“关联支持”是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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