TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How Clojure deals with objects

56 点作者 coding4all超过 10 年前

2 条评论

raspasov超过 10 年前
One important point is that once you instantiate like this (def a (ABC. &quot;Roger&quot;)) the &quot;name&quot; property is immutable by default, which is different from most OOP languages where you&#x27;d have to mark the property as &quot;final&quot; or something like that. If you really need mutable properties you&#x27;d have to use deftype instead of defrecord and mark the property with a the proper hint as described here <a href="https://clojuredocs.org/clojure.core/deftype" rel="nofollow">https:&#x2F;&#x2F;clojuredocs.org&#x2F;clojure.core&#x2F;deftype</a> . In most cases, unless you&#x27;re building a low level data structure, mutable properties are not needed; they are harder to reason about and much harder to get right in the face of concurrency and multiple threads.
评论 #8669288 未加载
nickik超过 10 年前
For those that want to go a bit deeper, prismatic has a information sheet.<p>See: <a href="https://github.com/Prismatic/eng-practices/blob/master/clojure/20130926-data-representation.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Prismatic&#x2F;eng-practices&#x2F;blob&#x2F;master&#x2F;cloju...</a>
评论 #8670017 未加载