warning -- print a warning
message
Introductionwarning(message) prints the warning
message.
Call(s)warning(message)
Parametersmessage |
- | a character string |
Returnsthe void object of type DOM_NULL.
Side
EffectsThe formatting of the output of warning is sensitive to
the environment variable TEXTWIDTH.
Related
Functions
Detailswarning(message) prints the message with
the prefix ``Warning: ''.warning may be used to print information about
potential problems in an algorithm. E.g., it is used in limit to provide hints. Cf.
example 3.warning is a function of the system kernel.
Example
1A warning:
>> warning("You should not do this!"):
Warning: You should not do this!
Example
2This example shows a simple procedure which divides two numbers. If the second argument is omitted, a warning is printed and the computation continues:
>> mydivide := proc(x, y)
begin
if args(0) < 2 then
warning("Denominator not given, using 1.");
y := 1;
end_if:
x/y
end_proc:
mydivide(10)
Warning: Denominator not given, using 1. [mydivide]
10
Example
3In the following call, the requested limit depends on
the paramater c:
>> limit(exp(c*x), x = infinity);
Warning: cannot determine sign of c [stdlib::limit::limitMRV]
limit(exp(c x), x = infinity)
The user can react to the warning by assuming some property for c:
>> assume(c < 0): limit(exp(c*x), x = infinity);
0
>> assume(c > 0): limit(exp(c*x), x = infinity);
infinity
>> unassume(c):