Mathematica writing style
- To: mathgroup at smc.vnet.net
- Subject: [mg18917] Mathematica writing style
- From: David Epstein <dbae at maths.warwick.ac.uk>
- Date: Mon, 26 Jul 1999 14:27:52 -0400
- Organization: University of Warwick
- Sender: owner-wri-mathgroup at wolfram.com
It seems that Mathematica is great for writing small programs, but things get difficult with larger programs because of lack of modularity. In particular, there seems to be a problem when one makes a typo and the mistake only emerges after the expression has been massaged by 20 different functions. I was wondering about ending every list of definitions of a function f, say, with something like f[x___] := error[f,x] and then producing a useful error with linenumber recorded using $Line. I also thought of introducing some typing into the variables. One has a limited amount of typing provided by the system, like f[x_List]. Could someone provide an example of how one might type a more complicated structure without having to specify the head? I don't fancy the idea of having a different head for each complicated structure, but maybe that's the right thing to do. Has anyone tried doing something like this? Is there some way of doing the error function stuff automatically for every function that one defines, without having to do it explicitly? Are there other measures one can take to stop errors propagating to somewhere far from their source? I haven't actually tried out my suggestion. Maybe there is some reason why it wouldn't work. David Epstein