6.60 assigned argument in a procedure (6.1.99)

6.60.1 Eddie Saudrais

I would like to test if an argument of a procedure is or not assigned. The result should be like (assuming test is the name of the procedure) :

>test(un) ; 

The number of arguments is not supposed to be known.

6.60.2 Joe Riel (14.1.99)

The procedure assigned will indicate whether its argument is assigned, however, in order to use this in a procedure (I assume that you want to do something else) the formal parameter must be typed with uneval, i.e.

test := proc(x::uneval) assigned(x) end:

It isn’t possible, I believe, to handle an indefinite number of arguments.

6.60.3 Dr. B. Wald (15.1.99)

This function is part of maple and called assigned . Inside a procedure it works with global and local names. But you have to be carfull. Take

f:=proc(x) assigned(x) end; 
Error, wrong number (or type) of parameters in function assigned

This is because the evaluation of a to 1 take place before the call of f . If you want to pass the variable a (instead of the value of a) to f, you have to use a uneval-quotation in the function call


A better way is to declare the parameter of f as an "eval to name" parameter

f:=proc(x::evaln) assigned(x) end;

Now f(a) gives no problem. I hope this helps.

6.60.4 Stanley J Houghton (15.1.99)

In rel 5 I make use of the uneval formal parameter type. This passes the name through, eg as ‘x‘ in the example proc below that does what you want I believe, and can be tested with the built in function ‘assigned‘:

> f:=proc(x::uneval)if assigned(x) then ("OK") else ("not OK") fi end: 
> f(un);f(deux); 
                               "not OK"

However, if you want the value of x you do need to use eval(x) for the value (or eval(x,n), where n is 2 or greater).