<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Well, using something other than a plain symbol after the FOR keyword<br>
isn't supported by DEFMACRO-DRIVER because that symbol is inserted in a<br>
normal macro definition. E.g.:<br>
<br>
</blockquote><div>yeah, I saw it in macroexpand and the macro flew into a rage if I tried to use any other variable than the first in the next form (like: (,kwd ,mm ... ). I ascribed it to my lack of knowledge and never thought it was illegal :) </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Well, contact the author? And although it may for you logically belong<br>
there, it adds a dependency to the date-calc package, which is, for a<br>
small library perhaps not worth it. Since iterate has contribs (or one,<br>
the postgres driver) I'd think it could be added there instead more<br>
easily. But I'm only using this library, so same goes here.<br>
<br>
</blockquote><div>I posted to date-calc-devel mailing list too, but as you say contribs might be a better place for this. How do I go about putting this into iterate/contribs?</div><div><br></div><div><br></div><div>Thanks for your time, and the inputs. I very much appreciate it.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Code remarks: I'd probably use &key instead of &optional, because<br>
wrapping date-calc:today every time I want to change skip-weekends would<br>
be too much work. Everything else is personal style, such as my habit<br>
for long names. And for just learning it looks good, imho.<br>
<br>
General remarks: use <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a>, #lisp and, if you like usenet,<br>
comp.lang.lisp, because there're certainly more people reading in those<br>
places. And you'll get more flames ;)<br>
<br>
Cheers,<br>
Olof<br>
<br>
[1]: <a href="http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm" target="_blank">http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm</a><br>
<br>
--8<---------------cut here---------------start------------->8---<br>
(iterate::defclause-driver (FOR year-month-date-vars FROM-DATE from-date-spec &optional TO to-date-spec BY (n 1) SKIP-WEEKENDS (skipval t))<br>
"Driver for iterating over dates. All dates are in (YYYY MM DD) format."<br>
(declare (ignorable to-date-spec))<br>
(iterate::top-level-check)<br>
(unless (and (listp year-month-date-vars)<br>
(every #'symbolp year-month-date-vars))<br>
(iterate::clause-error "~a should be a list of up to three variables: ~<br>
the year, month and day" year-month-date-vars))<br>
(mapc #'iterate::make-default-binding year-month-date-vars)<br>
(let* ((step-var (iterate::make-var-and-default-binding 'by :type 'fixnum))<br>
(fy (iterate::make-var-and-default-binding 'from-year :type 'fixnum))<br>
(fm (iterate::make-var-and-default-binding 'from-month :type 'fixnum))<br>
(fd (iterate::make-var-and-default-binding 'from-day :type 'fixnum))<br>
(ty (iterate::make-var-and-default-binding 'to-year :type 'fixnum))<br>
(tm (iterate::make-var-and-default-binding 'to-month :type 'fixnum))<br>
(td (iterate::make-var-and-default-binding 'to-day :type 'fixnum))<br>
(step `((multiple-value-setq (,fy ,fm ,fd)<br>
(get-next-day ,fy ,fm ,fd ,step-var ,skipval))<br>
(multiple-value-setq ,year-month-date-vars<br>
(values ,fy ,fm ,fd))))<br>
(test `(when (< (date-calc:delta-days ,fy ,fm ,fd ,ty ,tm ,td) 0)<br>
(go ,iterate::*loop-end*))))<br>
(setf iterate::*loop-end-used?* T)<br>
(iterate::return-driver-code<br>
:initial `((setq ,step-var ,n)<br>
(destructuring-bind (y m d)<br>
,from-date-spec<br>
(multiple-value-setq (,fy ,fm ,fd)<br>
(get-next-day y m d (- ,step-var) ,skipval)))<br>
(let ((spec ,to-date-spec))<br>
(multiple-value-setq (,ty ,tm ,td)<br>
(if spec<br>
(values-list spec)<br>
(date-calc:today)))))<br>
:next `(,.step ,test)<br>
:variable year-month-date-vars)))<br>
--8<---------------cut here---------------end--------------->8---<br>
<font color="#888888"><br>
--<br>
The world is burning. Run.<br>
<br>
_______________________________________________<br>
iterate-devel site list<br>
<a href="mailto:iterate-devel@common-lisp.net">iterate-devel@common-lisp.net</a><br>
<a href="http://common-lisp.net/mailman/listinfo/iterate-devel" target="_blank">http://common-lisp.net/mailman/listinfo/iterate-devel</a></font></blockquote><br><br clear="all"><br>-- <br>Audentis fortuna juvat<br>