"Do What I Mean" - a suggestion for improving Mathematica experience
- To: mathgroup at smc.vnet.net
- Subject: [mg96961] "Do What I Mean" - a suggestion for improving Mathematica experience
- From: David Bakin <davidbak at gmail.com>
- Date: Sat, 28 Feb 2009 06:42:20 -0500 (EST)
A few days ago I posted that Mathematica should have a "DWIM" feature - "Do
What I Mean".
In InterLisp, in the 80's, the DWIM facility was hooked into error messages,
and when invoked on a user error would poke around on the stack and in the
environment using some rules to describe common error situations and it
would uncover user errors and offer to correct them. Many of the errors
were simple spelling errors and it would correct a misspelled variable name
if it found an unbound variable but a similarly spelled variable was bound
in the environment.
Mathematica could benefit from this, and in fact, we at mathgroup could
supply the rules (and framework) as a useful group project.
If some guru would write the framework - trapping error messages somehow,
perhaps when they were written to the $Messages channel (by replacing the
default $Messages channel with something that would hook into the DWIM
function), or perhaps with some other hook like redefining Message - then
the rest of us could supply rules for the common errors. Especially the
common errors we see puzzling Mathematica newbies on this list.
I would suggest that the rules provide messages, hopefully with hyperlinks
to the documentation.
A true DWIM might also offer to rewrite the current expression and try it
again, but I don't know if that can be done given the hooks into Mathematica
that are currently available.
Some situations that could be addressed are:
1. User writes "xy" instead of "x y". Rule could inspect the expression
under evaluation and find (unevaluated) symbols like "xy" of the form
"<prefix><suffix>" where both "<prefix>" and "<suffix>" were either symbols
used in the expression or symbols bound in the environment. Rule would
explain the problem and offer to rewrite expression and try again.
2. Some expression using a user-defined function causes an error when
evaluating, or doesn't evaluate. Looking at the function, a rule finds
function calls where the function arguments' patterns include "_Integer" or
similar but the arguments given to it are not integers. Rule points to
documentation describing argument types required by the called function.
3. Similar to 2 above, but it finds function calls that do numeric
evaluation only or are optimized for numeric evaluation but the arguments
given to it are symbolic.
4. Result returned is machine precision very close to zero (that is,
with large negative exponent), but an error message complained of
singularity, or other ill-conditioning. Rule points to documentation
explaining about machine precision, and/or singularity, and offers to retry
the expression with more digits of precision, rewriting the expression to
Actually, now that I think of it, the DWIM facility needs also to be invoked
by the user because some of these situations don't cause error messages, but
only cause (wholly or partially) unevaluated expressions. So maybe the user
could be trained to type a word, like "Explain" after he didn't get the
result he wanted and the DWIM facility would look at the In and Out
arrays to find out what he's been doing recently.
I would be glad to contribute rules to the framework ... but I'm not yet up
to writing the framework. Hopefully one of the gurus here will find this
interesting (and possible) and provide a framework. Then the rest of us
could contribute rules that would improve the Mathematica experience for all
newcomers. (AES, I'm looking at you! :-) )
Prev by Date:
Re: Dificulty on Integrate function!
Next by Date:
Re: Dificulty on Integrate function!
Previous by thread:
wrong solution for double integral of piecewise function?