Way back when I was a wee lad I had been taught that a thunk is any
function that takes no arguments. My definition for my derived values
never took any arguments because they exclusively relied on global
variables.

For example:

(defn months_actively_renting
        "The number of months during the time we are in the rental business
that we are either trying to rent the house out or have rented it out"
        []
        (* (+ *Months_To_Find_Tenant* *Months_In_Lease*) *Lease_Cycles*))

That's all I meant by the term thunk.

On Feb 17, 10:20 pm, Richard Newman <holyg...@gmail.com> wrote:
> > I'm just trying to figure out what the right pattern is
> > because the fact that I'm forced to make the derived values into
> > thunks feels really wrong but I honestly don't know what's right in
> > the context of Clojure.
>
> I don't think you're using the term "thunk" correctly.
>
> A thunk is (usually) a no-argument function, typically used for things  
> like delayed evaluation, and typically capturing some environment. E.g.,
>
> (defn hello [thunk]
>    (println "Hello, " (thunk)))
>
> (defn make-name-thunk [name]
>    (fn [] name))
>
> (let [n (make-name-thunk "Jim")]
>    (println "Calling hello...")
>    (hello n))
>
> You are not making your derived values into thunks by this definition.  
> Your derived values are just that: values, computed by functions.  
> Compute them when you need them by invoking the appropriate functions  
> with the appropriate arguments.
>
> Can you explain what you mean by "thunk"?

-- 
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