argument checking, was: About submatrix and its meaning
Subject: argument checking, was: About submatrix and its meaning
From: Richard Fateman
Date: Mon, 23 Nov 2009 08:39:05 -0800
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.
>
Well, you could add more, and indent, like
check_args(foo,
assert(listp(a)),
assert(integerp(b)),
assert(a+b>c))
and you could have optional clauses to indicate error messages, or what
to do with failure, etc.
A remark:
in 1969 or shortly thereafter, I proposed extra syntax for matchdeclare,
tellsimp, tellsimpafter, which was
rejected (by Joel Moses, who thought... needs extra syntax).
So instead of something like..
f(a:true*x+b:true) -> g(a)+b
we got
matchdeclare([a,b],true)
tellsimp(f(a*x+b, g(a)+b).
compare this to Mathematica, which uses lots of extra syntax for patterns.
Anyway, it depends on what you are used to. I think the lisp
perspective tends toward "no new syntax".
RJF
> 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.
>
> Yes, it's reminiscent of the syntax for other declarations,
> but we needn't propagate it any further.
>
> I could be convinced that assert(P(x)) is OK, though.
>
>
>> The addition of more "syntax" is certainly not required.
>>
>
> Few things are necessary. Where does that leave us?
>
> Robert Dodier
>