MathGroup Archive 2012

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

Search the Archive

Re: Stop on message?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126666] Re: Stop on message?
  • From: Szabolcs HorvÃt <szhorvat at gmail.com>
  • Date: Wed, 30 May 2012 04:08:40 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201205260911.FAA07083@smc.vnet.net> <jpspa5$hb9$1@smc.vnet.net>

Hi Christoph,

Mathematica is used interactive most of the time.  It's very different
from most other programming languages in this respect.  In C, or even
in Python (which has an interactive shell), most of the time people 1.
first write the program and debug it 2. then they package it up and
give it to the user to run.  In Mathematica we typically don't write
stand-alone programs.  The system is usually used interactive, and the
most "packaged up" things are functions meant to be used by end-users.
 In other words: even the user is a programmer.

When you make a standalone program like a text editor, your users
shouldn't see any internal warnings/errors (on Linux these messages
are often printed to the console on they're pretty uninformative to
me, as a user, 95% of the time).  When you make a function for another
programmer to use, there are many reasons to keep those
errors/warning/informative messages.

Messages are one of the way functions communicate with users.  Here's
one example:

http://mathematica.stackexchange.com/questions/6055/how-to-get-rid-of-warnings-when-using-solve-on-an-equation-with-inexact-coeffici/12

The input Solve[-26.81 == 194 k + k*l*32.9 && 22.2 == -74 k + k*l*
59.7, {k, l}] issued a warning message, prompting the user to check
the answer.

Another example is FindMinimum[x^2/2 + Cos[x], {x, 1}] (from the
docs), where an answer *is* returned, but there's also a warning that
it might be incorrect.  Version 5's General::spell messages are yet
another example.

There's no "writing" and "debugging" step here.  This is the usual way
to use the system.  Solve and FindMinimum are high level functions
which are probably more commonly typed than used as parts of other
functions.  These examples could occur in any usual interactive
session of Mathematica.

So, to sum up:

Usually there's no "development phase" when you work with Mathematica.
 If there is, you're probably developing a "library" for users who are
going to use it to "program" (actually just use the system
interactively), and therefore they'll need messages again.

I hope this clears it up.

On 29 May 2012 18:07, Christoph Lhotka <christoph.lhotka at fundp.ac.be> wrote:
> Hi,
>
> =C2 in my opinion messages in Mathematica are generated during the evaluation
> process to give
> some kind of "meta"-information about 1) what is going wrong or 2) what you
> need to know
> to check by yourself to know of the returned result is correct.
>
> I would like to compare this information with the concepts of "errors" and
> "warnings" produced
> by a compiler during the process to produce a program.
>
> Seeing "Mathematica messages" in this flavour any input which produces a
> message should be
> seen as wrong or not working properly and therefore be modified as long as
> there are no
> messages left at all.
>
> I therefore do not see a reason yet why I should use messages outside the
> development
> phase of a project.
>
> Can you provide me with one?
>
> Thanks,
>
> Christoph
>
>
>
>
>
> On 05/29/2012 11:47 AM, Szabolcs Horv=C3=A1t wrote:
>>
>> There were two replies suggesting to use Check[] to abort evaluation
>> when a message is generated.
>>
>> Note that while Check does return a different result if a message was
>> generated, it does not actually interrupt evaluation (it completed the
>> evaluation of 'expr').
>>
>> See here for an example:
>>
>>
>> http://mathematica.stackexchange.com/questions/5534/check-does-not-interrupt-evaluation-of-the-expression-when-a-message-is-emitted
>>
>> Please see here for a method that will reliably abort immediately when a
>> message is generated.
>>
>>
>> http://mathematica.stackexchange.com/questions/1512/how-to-abort-on-any-message-generated
>>
>> On 2012.05.27. 10:40, Sseziwa Mukasa wrote:
>>>
>>> Check[expr,Return[]]
>>>
>>> On May 26, 2012, at 5:11 AM, Ralph Dratman<ralph.dratman at gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> Is there a simple way to get Mathematica to stop evaluating (like
>>>> Interrupt) whenever a message is issued?
>>>>
>>>> I realize the debugger has that feature, but I would prefer not to use
>>>> it in this case.
>>>>
>>>> Thank you.
>>>>
>>>> Ralph Dratman
>>>>
>>
>



  • Prev by Date: Re: GraphPath With Edge Weights
  • Next by Date: Re: Sqrt of complex number
  • Previous by thread: Re: Stop on message?
  • Next by thread: Re: Stop on message?