Hi Stuart,
>
> Components are records in order to support the dependency-injection
> features of `component/start-system`, which work via `assoc`.

That was the only reason that I could imagine but I wanted to double
checked here :) I'm always inclined to think in performance reasons that I
don't know yet

I was thinking in having a protocol to replace this practical `assoc`
behaviour of defrecor. So we can get components working with a global state
tree structure instead of local state

Thanks for having the time to answer this question!
Juan

2015-04-29 18:04 GMT+02:00 Stuart Sierra <the.stuart.sie...@gmail.com>:

> Hi Juan,
>
> Components are records in order to support the dependency-injection
> features of `component/start-system`, which work via `assoc`.
>
> There are potentially many other ways to do dependency injection, but I
> found `assoc` to be practical.
>
> If you want to create a component that has a Lifecycle but no
> dependencies, then `reify` will work just fine.
>
> If you want to create a component that has dependencies but no Lifecycle,
> then an ordinary Clojure map will work.
>
> –S
>
>
>
> On Wednesday, April 29, 2015 at 2:41:54 PM UTC+1, Juan A. Ruz @tangrammer
> wrote:
>>
>> Hi guys,
>> I'm just wondering the pros/contras that justify to choose defrecord vs
>> reify as component fn constructor.
>>
>> in the component README we can read
>> "To create a component, define a Clojure record that implements the
>> Lifecycle protocol."
>>
>> Yes I know that "defrecord creates an immutable persistent map which
>> implements a protocol." but I think that the same thing can be achieved
>> with reify (BTW: "om" way to define component) over a persistent map...
>>
>> Do you think there are more reasons to set defrecord as default base fn
>> for components?
>>
>> Thanks in advance
>> Juan
>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/xqU_JSFWK-k/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to