I don't see why you couldn't simply check to make sure that there are
no arguments without either default or supplied values.  As I wrote
above, "If you left the arguments incomplete and unkeyworded it would
apply what you put preferentially to the first arguments in the list
without a default value."  If there are any null arguments left over,
the macro could throw an exception.

The basic rule is, "accept what you can, and only error our if you
absolutely must."

(Of course this variable application rule might get confusing in
practice, at least without help from the IDE.)

I think it's better than just a flat arguments list, because 1) it
allows you to specify defaults and 2) it gives you the option of
naming arguments by keyword.  How can you do that with flat argument
lists?

My point is that the option of naming arguments is implicitly there
any time you write a function, because variables have names; and there
is no way to mistake a default value for a variable.  So you might as
well use these built-in distinctors.

You could even do a little branching from within argument lists.
Suppose for instance you had something like

(dfnsk demo-branch [x 0 0 1 y 0 1 0] ....)

There can be only one default per variable, so what are the other
values?  These could only be possible passed-in values.  x=0, y=1 is
the first branch, x=1, y=0 is the second.  Within the function body,
you would have a predicate available that tells you what branch you
are on, so for instance you could write something like

   (cond (branch? 1) ...
         (branch? 2) ...)

or, if you passed in multiple function bodies after the argument list,
(kind of like the variable arity thing), the first would be for the
first branch, the second for the second, etc.

Another 'generality' that could be added is to match arguments by type
whenever there is a type annotation in the function definition and a
discrepancy in the call; so for instance if you had a number of
symbols that were supposed to be passed last, and you passed a symbol
somewhere else, it would be applied to the first symbol-type argument
in the function list without throwing an error.

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

Reply via email to