Linked Questions
12 questions linked to/from What are the best practices / most common / idiomatic ways to report errors in Mathematica?
1
vote
1
answer
3k
views
How to print a warning/error message from my own module? [duplicate]
I would like to print a warning/error message from my own module. Of course I could use Print["WARNING: my warning"] but in all the output this would be barely ...
2
votes
1
answer
341
views
Why evaluation doesn't fail if arguments are invalid? [duplicate]
Sorry for a noob question, but this is something that I wonder about each time I work with Mathematica.
Coming from standard programming languages (Python and Java), I expect my functions to fail ...
597
votes
19
answers
154k
views
Where can I find examples of good Mathematica programming practice?
I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
16
votes
4
answers
1k
views
How to check the style and number of arguments like the built-in functions?
Given that I have a function sqrt[x] that I must check the style and number of argument x.
I can do like this:
...
34
votes
1
answer
1k
views
which is better, using Assert[] or manual checks on arguments and other computations?
I never used Asserts in Mathematica, but trying to see what advantage they have over just argument check and additional definitions of the function to capture unwanted input.
For example, which one ...
8
votes
1
answer
193
views
How to use Message with an error string without predefining it first?
I need a very simple error reporting using Message. But I do not want to pre-define each error message separately as shown What are the best practices / most common / idiomatic ways to report errors ...
8
votes
1
answer
186
views
What is an example of of idiomatic "typed" WolframScript?
I'd like to make my own "typed function" in WolframScript. Suppose the type we desire is called money, and we'd like to make a function called ...
6
votes
2
answers
98
views
Assert no unevaluated function applications
Background
Suppose I have begun a fresh kernel session, and I have defined the following function alone:
F[x_, y_] := x + y;
One expected use of ...
3
votes
1
answer
316
views
How to force error on pattern match failure?
For example, suppose that foo is defined like this.
foo[x_Integer, y_Integer] := x + y;
Then, any expression with head ...
2
votes
0
answers
433
views
How to handle exceptions and failures in Mathematica?
In python I can write fallback values like:
...
2
votes
1
answer
96
views
How to enable automatic "grammar check" for MMA? [duplicate]
The special evaluation mechanism of MMA might make it more likely for MMA users (especially new users) to make mistakes and more difficult to find them.
For example, one may have defined a function
...
0
votes
0
answers
49
views
Inspecting the evaluation stack on computation abort [duplicate]
It happens often that a computation starts consuming more memory or time when it encounters an expression with elements in the input that are in some unexpected form.
Is there some way to abort ...