argument checking, was: About submatrix and its meaning



Robert Dodier wrote:
> On 11/23/09, Richard Fateman <fateman at cs.berkeley.edu> wrote:
>
>   
>> foo(a,b,c):=  (
>>    check_args(foo,[a,listp],[b,integerp],[[a,b,c], a+b>c]),
>>     
>
> This is needlessly clumsy and incomprehensible.
> check_args merges into the body of the function where it is
> easily overlooked, declarations for all variables are mashed
> together, and there is no syntactic clue that the variables are
> different from the predicates.
>   
I think your example with the lambda is also clumsy and incomprehensible
if you have several arguments with complex lambda predicates for each
one.  The simple cases like listp, integerp, etc., are fine, though.  Of
course, we could go a long way by using *descriptive* variable names
instead single-letter ones too.  Then listp, integerp, etc. are almost
redundant, except for the verification of such.  And then the check
could be in the body too.

Richard's proposal was more complex than I had in mind.  I was thinking
of something simple like check_type(a, listp), check_type(b,
lamba([x],...)), etc.

Each has its pros and cons.

Instead of discussing these things, perhaps we should be discussing what
do we really want maxima to be able to do, and how do we want to express
such things.  (Or maybe that will just descend into blackhole?)

Ray