In general, I find that multiple arguments types for a function confusing.
If dotimes is going to take multiple types it should be a multifn. That
seems to imply a performance hit.
I think Clojure wisely does not (or rarely does not?) allow for multiple
types to be passed into a function.

On top of that it's trivial to produce a macro on top of dotimes that does
what you want that doesn't spend time checking the type of it's argument.

On Sat, Feb 21, 2009 at 11:10 PM, Mark Volkmann
<r.mark.volkm...@gmail.com>wrote:

>
> On Sat, Feb 21, 2009 at 8: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?
>
> Why do you say it would be a breaking change? I just got the following
> to work with minimal changes to the dotimes macro.
>
> (dotimes 3 (println "Ho"))
> (dotimes [n 4] (println n))
>
> So both forms work with a single macro definition.
>
> Here's what I did.
>
> 1) Wrap the body of the macro inside the following:
>
>  (let [new-bindings (if (integer? bindings) ['n bindings] bindings)]
>    ...
>  )
>
>  This creates the required binding when only an integer is passed and
> using the supplied value for bindings otherwise.
>
> 2) Change every occurrence of "bindings" in the body to "new-bindings".
>
> 3) Move the (defmacro dotimes ... ) to just before (defn make-array ...).
>    That's the first time it's used in core.clj and it will not be
> after the definition of "integer?".
>
> Is there a reason to not make this change?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> >
>

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