Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Need features to make kernel and user functions bullet proof

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84054] Need features to make kernel and user functions bullet proof
  • From: "Ted Ersek" <ted.ersek at tqci.net>
  • Date: Fri, 7 Dec 2007 06:55:43 -0500 (EST)

Need features to make kernel and user functions bullet proofWe can
overload functions that are part of the Mathematica language, and this
is good.  However, we often hear in the MathGroup that you can easily
break the kernel by changing kernel functions. This wouldn't be so risky
if users could not indirectly change the way functions such as Solve,
Simplify, NDSolve, etc. perform. I mean a user should be able to change
what Simplify does by making a new definition for Simplify, but changing
functions such as Thread, Map, or Apply should not change Solve, Simplify,
or NDSolve. Besides that users who are writing their own functions should
be able to ensure their functions cannot be broken inadvertently.

-------------------------------------------------------------------------
Also notice you can change the default options of a protected symbol
without first calling Unprotect. As a result a user can seriously break
a lot of functions with lines such as

  SetOptions[ReplaceRepeated,MaxIterations -> 1];
  SetOptions[Map,Heads->True];

Mathematica needs a new attribute called OptionsProtected.
OptionsProtected::usage="OptionsProtected is an attribute that prevents
the default options of a symbol from being modified."
-------------------------------------------------------------------------

Now about preventing inadvertent changes to a functions definitions. One
way WRI could provide this capability would be to have all symbols in the
System` context also in a context called DefaultDefinitions`. All Symbols
in context DefaultDefinitions` would have attributes {OptionsProtected,
Protected, Locked}.  That would make it impossible for a user to modify
features in the DefaultDefinitions` context.

Things that happen automatically behind the scenes should use symbols
from the DefaultDefinitions` context to ensure everything always
works correctly.  So for example when definitions are automatically
added to DownValues[f], UpValues[f], etc.  they should be created using
DefaultDefinitions`HoldPattern, and DefaultDefinitions`RuleDelayed.

Imagine what could happen if you changed the meaning of RuleDelayed in
the current Mathematica.

-------------------------------------------------------------------------=
-
WRI could also give us a new function called SystemDefaults that would 
do the following.

Attributes[SystemDefaults]={HoldRest};

SystemDefaults[All, expr] replaces all symbols in expr that are in
the System` context with the same symbol from the DefaultDefinitions`
context. Once the replacements are made the new form of expr evaluates.

SystemDefaullts[{symb1, symb2, ...},expr]  selects from {symb1, symb2,
...} Symbols in the System` context and replaces each instance of
these symbols in expr with the same symbol from the DefaultDefinitions`
context. Once the replacements are made the new form of expr evaluates


  • Prev by Date: Re: Re: Re: Mathematica: Long divison for polynomials
  • Next by Date: BarChart[{1,2},Frame->True]
  • Previous by thread: Re: Exact roots of transcedental functions
  • Next by thread: Re: Need features to make kernel and user functions bullet proof