ok. Now one more question please: your solution looks also slightly more complex from the user's perspective: he has to deal with the *parser* object and the future object (returned by schedule-parse).
So the question is: what does your solution provide that the sketch of my solution does not ? Do you see my solution harder to implement ? Do you see your solution more generic ? Smth else ? 2010/8/5 Meikel Brandmeyer <m...@kotka.de> > Hi Laurent, > > On Aug 5, 11:07 am, Laurent PETIT <laurent.pe...@gmail.com> wrote: > > > Looks complex. > > Hmm.. Maybe we can save the agent and use an atom? (For some reason, I > thought, it wouldn't work with an atom...) > > (def *parser* (atom nil)) > > (defn schedule-parse > [] > (reset! *parser* (delay (parse-stuff)))) > > (defn trigger-parse > ([] (trigger-parse 0)) > ([delay-in-millis] > (future > (when (pos? delay-in-millis) > (Thread/sleep delay-in-millis)) > @@*parser*))) > > > One think I forgot to mention is that by making the datastructure > implement > > the future API, I *desire* the ability to cancel the future while it's > still > > sleeping : so that when the user types fast, intemediate values are not > > computed at all. > > Well. You can. If you cancel the trigger-parse future while it's > sleeping, the parse run will not be triggered. You can even put more > logic into schedule-parse and only update the delay in the atom if > really necessary. > > Sincerely > Meikel > > -- > 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