On Saturday 29 November 2008 07:29, Randall R Schulz wrote:
> On Saturday 29 November 2008 06:55, Randall R Schulz wrote:
> > ...
> >
> > It's a good technique, though, to see what the compiler is going to
> > be asked to translate after all players between the form as
> > submitted and the compiler have done their thing.
>
> Or is it?
>
> ... I'm working my way through Stuart H.'s book.
> I'm on the sequence section (4.2) and just got to "for". 
> Here's what I did / found:
>
> ...
>
> So seeing that "for" is a macro, I thought I'd see what it produces.
> I started with the example included in the doc string:
>
> user=> (macroexpand '(take 100 (for [x (range 100000000) y (range
> 1000000) :while (< y x)] [x y]))) (take 100 (for [x (range 100000000)
> y (range 1000000) :while (< y x)] [x y]))
>
>
> So next I tried macroexpand -ing just the (for ...) sub-form:
>
> user=> (macroexpand '(for [x (range 100000000) y (range 1000000)
> :while (< y x)] [x y])) (let* [iter__3869 (clojure.core/fn iter__33
> [s__34] (clojure.core/when-first [x s__34] (if true
> ... 
>
>
> I'm somewhat confused by this, but I gather it has something to do
> with "take" being lazy?

And, continuing my exploration, the confirmation of this hunch comes 
shortly after, in section 4.3.

This does, at least, impose a caveat on the use of macroexpand as a tool 
for understanding what your code really says (and does).


Randall Schulz

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to