doseq is a macro, not a function, and its expansion expands the loop right
in place :

$ java -cp clojure/clojure.jar:clojure-contrib/clojure-contrib.jar
clojure.contrib.repl_ln
Clojure 1.1.0-master-SNAPSHOT
1:1 user=> (require 'clojure.contrib.pprint)
nil
1:2 user=> (clojure.contrib.pprint/pprint (macroexpand-1 '(doseq [x (range 0
10)] x)))
(clojure.core/loop
 [seq_9
  (clojure.core/seq (range 0 10))
  chunk_10
  nil
  count_11
  (clojure.core/int 0)
  i_12
  (clojure.core/int 0)]
 (if
  (clojure.core/< i_12 count_11)
  (clojure.core/let
   [x (.nth chunk_10 i_12)]
   (do x)
   (recur seq_9 chunk_10 count_11 (clojure.core/unchecked-inc i_12)))
  (clojure.core/when-let
   [seq_9 (clojure.core/seq seq_9)]
   (if
    (clojure.core/chunked-seq? seq_9)
    (clojure.core/let
     [c__5257__auto__ (clojure.core/chunk-first seq_9)]
     (recur
      (clojure.core/chunk-rest seq_9)
      c__5257__auto__
      (clojure.core/int (clojure.core/count c__5257__auto__))
      (clojure.core/int 0)))
    (clojure.core/let
     [x (clojure.core/first seq_9)]
     (do x)
     (recur
      (clojure.core/next seq_9)
      nil
      (clojure.core/int 0)
      (clojure.core/int 0)))))))
nil
1:3 user=>

HTH,

-- 
Laurent

2009/12/15 Greg Harman <ghar...@gmail.com>

> Why does that work? The same recursion happens in the finally. There's
> a layer of indirection now, but the doseq was already a layer of
> indirection between the finally and doseq's internal recur.
>
> I see from the linked thread above that the basic issue is a known
> implementation issue with Clojure to limit complexity - given that,
> perhaps doseq (and any other out-of-the-box macros/functions that are
> internally implemented with recur, or otherwise trigger that
> exception) should be documented as having this effect.
>
> --
> 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<clojure%2bunsubscr...@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 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

Reply via email to