> I don't think it's possible to ever have apply not evaluate all its > arguments? I think this is what Nathan was saying. >
Cedric is right that apply, itself, is strict and evaluates its arguments as one might expect. But I'm not referring to manual thunking/delaying your arguments to mimic laziness in a strict language. What I'm trying to understand is that one is able to write a polyvariadic function that *doesn't* completely realize the "& rest" parameter (but only in the case that the fn is invoked via apply with a lazy seq argument). It's this combination of requirements that means apply should *not* construct a tuple (as in clojure-py) or cons arguments together into a list (as I'm currently doing in clojure-scheme) as these operations will cause the realization of the entire applied sequence. > Given the above > example, is there anyway to not have the side effects automatically > run when invoking apply? > Yes. If you bury an effect into the lazy-seq at some position n, it won't be realized unless the applied function is either fixed-arity up to n, or chooses to force the lazy-seq up to n (modulo chunked evaluation). My question is what would require this sort of function? Is there a use-case for a function that expects to be called via 'apply' to avoid evaluating some of its arguments? (Again, this isn't a question of thunking; The user of this hypothetical function can apply it with a strict list or a lazy list and no code needs to change--I, as a caller, don't need to explicitly thunk arguments for laziness and the fn doesn't need to explicitly force/dereference them). Put another way: why does apply need to promise not to realize its seq argument? -- 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