If you want your library to be dead code elimination friendly don't use top
level data structures.

It's a very simple rule.

David

On Tue, Mar 10, 2015 at 8:19 PM, Mike Thompson <[email protected]>
wrote:

> This issue from David Nolen, caught my eye:
> https://github.com/andrewmcveigh/cljs-time/issues/21
>
> Feels like there is important information there, but I just don't know
> enough to interpret what's said. Can anyone help?
>
> If I have this:
>
> (def x  {:a 1 :b 2})
>
> David is saying that x can't be dead-code-eliminated. Correct?
>
> If so, the solution he talks about is?
>
> ;; Replacing PersistentHashMaps with functions?  Can't be right. I think
> I'm being too literal here
> (def  x  ((fn []  {:a 1 :b2})))
>
> ;; more likely this?
>
> (defn x
>   []
>   {:a 1 :b 2})
>
> Ie. you must now "call" x to get the map.
>
> If this solution is the right one, doesn't that mean we would be
> inefficiently constructing the (potentially large) hashmap inside x on each
> call.
>
> --
> Mike
>
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to