Next: Implementation Up: Construction Previous: Package documentation

Parameter and option checking

Mathematica provides a facility for data-typing of function arguments. When a pattern match for an argument fails the unevaluated function is returned.


In[4]:= g[x_Integer]:=x^2;
In[5]:= g[2.3]
Out[5]= g[2.3]
Since there are many options available in the package, it is preferable to perform parameter type checking for all arguments and options using a conditional test (/;). An appropriate error message is then output [16]. This behaviour is demonstrated with an example of incorrect input syntax, showing the close correspondence with Mathematica's own internal error messages.

In[6]:= FortranAssign[x,Pi t,AssignIndent->wrongtype]

  FortranAssign::args: 
    The option AssignIndent did not evaluate to a string or a
    positive integer.

Out[6]= FortranAssign[x, Pi t, AssignIndent -> wrongtype]
The option AssignIndent specifies an ASCII string prepended to the output.


bondaren@thsun1.jinr.ru