Question: parameter gymnastics

Hello again!

I am writing a procedure of which the body is done, I "only" need to take care of the input in a clever way, which is where I'm stuck. I want to make it as simple as possible for the end user. The procedure has the following parameters:

- 2 matrices of type 'Matrix' [required], say A and B

- either a list L (default []) or a symbol S (but one of them is required)

- an optional symbol v::symbol:=t

What's the best way of handling these?

If I make a procedure myproc:=proc() ... end proc: and try to use typematch or select(type,...), then I run into the problem that I have two matrices that I have to tell apart (because of the body of the procedure), so I believe I need an ordered parameter sequence as in myproc:=proc(A::Matrix,B::Matrix).That way, I know exactly which is which.

Should I make keyword parameters for L and S (and v?) or simply handle them with _rest? The problem with _rest is that I need some sort of type matching, and there's two symbols there (S and v), and if S is given instead of L, then I have two symbols and can't tell them apart. Since I can either have L or S but not both, that means that there is a situation where I can tell them apart, but in general I can't.

Is there a way to have an ordered sequence, in which a particular parameter can be one of two (or more) types but have defaults? I know that trial:=proc(x::{list,symbol}) ... end proc: is possible but it's not really what I'm looking for.

Cheers,

Fred.

Please Wait...