Pref::typeCheck -- type
checking of formal parameters
IntroductionPref::typeCheck determines the kind of type checking of
procedure parameters.
Call(s)Pref::typeCheck(value)
Pref::typeCheck( <NIL>)
Parametersvalue |
- | one of Always, Interactive,
None, or NIL |
Returnsthe last defined value
Related
Functionsargs, DOM_PROC, domtype, hastype, proc, testargs, testtype, Type, type
DetailsType can be used. With Type, user defined types can be easily
added to the system to extend the type checking mechanism.Pref::typeCheck can be:
NoneInteractiveAlwaysInteractive means: When the user is
calling a procedure f, their parameters will be checked,
but all procedures, that will be called by the user called procedure
f, performs no type checking.Pref::typeCheck without arguments returns
the current value. The argument NIL resets the default
value, which is Interactive.
Example
1The parameters of the procedure f must be
an identifier followed by an integer:
>> f:= proc(a : DOM_IDENT, b : DOM_INT)
begin
evalassign(a, b)
end_proc:
f(a, 2)
2
Now a has the value 2, but an
identifier is expected:
>> f(a, a + 2)
Error: Wrong type of 2. argument (type 'DOM_INT' expected,
got argument 'a + 2');
during evaluation of 'f'
Backgroundproc(a : DOM_IDENT, b : Type::Integer).
That means: a must be of the type DOM_IDENT
and b must be of the type Type::Integer.Type
covers generally more objects as the MuPAD kernel types.