absolutely wild guess:

the compiler builds a call graph and any function that is not part of the
call graph is eliminated

(def x {:a 1 :b 2}) does not return a function but x maybe used inside some
function, so I'm assuming the compiler just leaves it there

why would it be hard to see if x is  or is not used by some function that
is in the call graph? i think that is a more involved job that building a
call graph






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

> On Wednesday, March 11, 2015 at 11:19:28 AM UTC+11, Mike Thompson 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.
>
>
> Two follow-on questions:
>
>    - Could this problem with PersistentHashMaps not being dead code
> eliminated be fixed with correct application of the Closure's
> "@nosideeffects" tags?  Ie. if the function which creates
> PersistentHashMaps had this tag in its comment?
>
>     - I assume that the following is not a problem:
>
> (defn y [] :y)
> (def x  y)
>
> If both x and y are never used then both will be dead code eliminated.
>
> --
> 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