The intuitive behaviour (to me) would be that :pre is applied to every recur as stated and post is applied only to the eventually returned value and this *_should_ *be considered a bug. My logic is as follows:
1. A (pure, for simplicity of this argument) function, in the absence of erroneous inputs or bugs, should behave the exact same with and without pre/post conditions. 2. The function body should be the same with and without pre/post conditions. That is I expect to be able to take any function and add pre/post conditions - given #1 above, there shouldn't be any difference except that the version with conditions will throw an exception when bad inputs/outputs are detected. That is, I think of pre/post conditions like I think of logging. 3. Pre conditions should be applied to the function inputs whenever the function is given inputs - since recur essentially calls the function again, pre conditions should therefore be applied to each recur. 4. Post conditions should be applied to the function return value. Since recur doesn't really return anything (and is working on intermediary possibly incomplete state anyway), post conditions should be applied only to the final returned value. The reason I consider this a bug is because it violates 1, 2 and 3. Not considering it a bug because of implementation details is, IMHO, not the right approach, even if the patch never gets accepted and this never gets fixed. That's my opinion anyway, hopefully its useful in some way. On 25 July 2014 23:37, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > Yes :pre should apply to every recur, like usual without :post. > > user=> ((fn [a] {:pre [(number? a)]} (recur 'a)) 1) > AssertionError Assert failed: (number? a) user/eval5376/fn--5377 > (form-init687485383035947214.clj:1) > > That probably means that if :post is present, the preconditions should be > moved inside the inner loop instead. > > I can see how destructuring makes this a little tricky. > > Thanks, > Ambrose > > > On Sat, Jul 26, 2014 at 6:27 AM, Steve Miner <stevemi...@gmail.com> wrote: > >> My first patch was buggy with destructured args so I had to withdraw it. >> >> While working on a better patch, I came up against a related issue: >> Should the :pre conditions apply to every recur "call". I'm saying no. The >> :pre conditions should be checked just once on the initial function call >> and never during a recur. Any other opinions? >> >> On Jul 25, 2014, at 10:57 AM, Steve Miner <stevemi...@gmail.com> wrote: >> >> > Ticket CLJ-1475 with my patch. >> > >> > http://dev.clojure.org/jira/browse/CLJ-1475 >> >> -- >> 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 >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.