Next: Renaming functions
Up: Construction
Previous: Reformatting expressions
In[1]:= mainformat[expr_,FortranForm]:= FortranForm[expr];
In[2]:= badformat[expr_] :=
Block[{ArcSin,ASin},
Format[ArcSin[y_],FortranForm]:= ASin[y];
mainformat[expr,FortranForm]
];
In[3]:= badformat[ArcSin[a+b]]
Out[3]= ArcSin(a + b)
The format rule for ArcSin does not hold within the body of mainformat
and is never applied to the function. It is therefore difficult to implement a
modular design using this approach which, at the very least, makes code
maintenance difficult. A preferred approach is outlined in the next section.