On Feb 21, 9:53 pm, André Thieme <splendidl...@googlemail.com> wrote:
> On 21 Feb., 18:24, Mark Volkmann <r.mark.volkm...@gmail.com> wrote:
>
> > Currently the dotimes macro requires its first argument to be a vector
> > for binding a variable to the number of times the body should be
> > executed. Inside the body, that variable is bound to the values from 0
> > to that number minus 1. How about changing this macro to also accept
> > an integer as the first argument instead of a binding vector for cases
> > where the number isn't needed in the body.
>
> I don’t find this very interesting.
> There several variants of how dotimes could be, but the one that we
> currently have is the one that is used since a few decades in Lisp,
> and it is the one that makes very much sense.
>
> > For example,
>
> > (print "Santa says")
> > (dotimes 3 (print "Ho"))
> > (.flush *out*)
>
> (print "Santa saysHoHoHo")
>
> How often do you really want to repeat the same side effect many times
> in a row?
> Why does it hurt to just say (dotimes [i 100] ...)?
> This will not reduce readability dramatically, but is a consistant
> use of dotimes. It also does not reduce productivity.
> Why make a breaking change for this?

I second that.  In my (somewhat limited) lisp experience, you can
streamline the code and make it more readable by defining an
appropriate macro.  In this instance, you may want to define this
macro that would allow you to say:

(print-times  3 "ho")

In lisp you would define it as (untested):

(defmacro print-times (reps text)
`(do-times (i ,reps)
(print ,text))

(Not trying to force-feed lisp, just that I do not know the closure
syntax).

In my practice, almost every project (no matter how short it is)
starts by writing raw code, and then, when I see what is being done
often, replacing parts with macros that simplify the code and make it
easier to read.

Mirko


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