Perhaps the assert-args macro should be public?

Since compile-time verification of your macros is essentially free and
it avoids runtime errors that may be pretty difficult to diagnose, it
seems to me to be very good practice to check your macro arguments.

Something I still do all the time is write:
(defn my-fn (arg1 arg2) blah)

This is probably due to my weird half background in CL.  But anyway,
it causes a weird unrelated error where a clear error would state that
defn expected a vector of arguments to the function and not a list,
you antediluvian fool!.  Ditto with let, but it appears that is
addressed.

A likewise, utterly confounding error is when you defmulti with a
dispatch function of the wrong arity.  When you call the resultant
multi function there was very little connection between the error and
where the problem was.

Perhaps this could be my little project.  How difficult would it be to
extend defmethod such that it checked the dispatch function and
ensured that the dispatch function had at least the arity of the
defmethod function?

Chris

On Jan 5, 12:38 pm, Chouser <chou...@gmail.com> wrote:
> On Sat, Jan 3, 2009 at 6:20 PM, Olov Lassus <olov.las...@gmail.com> wrote:
>
> >> The 'let' macro already has a similar check.
>
> >> Attached is a patch that adds even-ness and related assertions to a
> >> bunch of core macros.
>
> > That's better - I applied the patch and it's working as expected here.
>
> Thanks.  I've created an issue for this:
>
> http://code.google.com/p/clojure/issues/detail?id=31
>
> --Chouser
--~--~---------~--~----~------------~-------~--~----~
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