AlexPeake (69) [Avatar] Offline
#1
I cannot follow what you are saying in:

This situation is illustrated here, where daily-report is an imagined function that ran a report for a day –

(let [now "2009-10-22"]
(shadow-time (daily-report now))

This wouldn’t work as expected, since the value of now that the daily-report function sees would not be "2009-10-22", but a number like 1259828075387. This is because the value set up in the let form above gets captured by the one in the let form generated by the macro.


Where does "...would not be "2009-10-22", but a number like 1259828075387..." happen?
amitrathore (132) [Avatar] Offline
#2
Re: My confusion in Generating Names p. 170
I don't have the manuscript in front of me, but if I remember right, the expansion of shadow-time would create another let form, nested inside the outer let where now is set to "2009-10-22". This would cause the value of now to be shadowed. The daily-report function wouldn't see "2009-10-12" but whatever the new value of now would be, in this case, a time-stamp.

This doesn't happen in reality though, thanks to Clojure's take on macro hygiene. Instead of leaving the name in the let form as an unqualified 'now', it expands it into a namespace qualified <ns-name>/now... which if it didn't exist, would result in an error.

Hope this explains it...
AlexPeake (69) [Avatar] Offline
#3
Re: My confusion in Generating Names p. 170
Thanks for the explanation. The confusion is coming from shadow-time. What does it do? Perhaps the defnition of it would help.
amitrathore (132) [Avatar] Offline
#4
Re: My confusion in Generating Names p. 170
You're right... it is a mistake in the manuscript... shadow-time isn't defined anywhere... I'll be sure to fix it, thanks!