I think this behavior is as-intended, although I agree that it is confusing.
The reason for this stems from the fact that lazy-cat returns a seq, and the only allowed representation for the empty seq is "nil" (i.e., Java null). Thus, lazy-cat must always do enough evaluation to know whether to return an Object representing a non-empty seq, or nil, even if you never explicitly ask for any of the elements of the returned seq. This means evaluating each of its arguments in turn until it finds an argument x for which (seq x) is non-nil. HTH, Jason On Jan 30, 3:55 pm, André Thieme <splendidl...@googlemail.com> wrote: > Some minutes ago I found out that there is a mismatch between my > interpretation of lazy-cats docstring and the actual behaviour of that > macro. > > Its docstring says: > "Expands to code which yields a lazy sequence of the concatenation > of the supplied colls. Each coll expr is not evaluated until it is > needed." > > I would expect that in > (take 0 (lazy-cat [(println 10)] [(println 20)])) > no evaluation is needed. If lazy-cat were lazy it would return > immediately, > without concatenating anything. > > Maybe the docstring can get modified? > Although I personally see this current behaviour as not correct, while > the > docstring is right. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---