Skip to content

Commit

Permalink
Errors.m: Add DefFn function for defining functions
Browse files Browse the repository at this point in the history
This means that ErrorDefinition can be applied automatically.  In future we could add profiling and stack information for backtraces.
  • Loading branch information
ianhinder committed Oct 7, 2011
1 parent 4c20e5c commit bfe6bb6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tools/MathematicaMisc/Errors.m
Expand Up @@ -16,6 +16,7 @@
Terse = 2;
Info = 3;
InfoFull = 4;
DefFn;

Begin["`Private`"];

Expand Down Expand Up @@ -93,6 +94,14 @@
x[args___] :=
ThrowError["Invalid arguments to "<>ToString[x], {args}//FullForm];

SetAttributes[DefFn, HoldAll];

DefFn[def:(fn_[args___] := body_)] :=
Module[
{},
ErrorDefinition[fn];
def];

End[];

EndPackage[];
Expand Down

0 comments on commit bfe6bb6

Please sign in to comment.