MathGroup Archive 2009

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

Search the Archive

Re: Limiting the number of messages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103837] Re: [mg103810] Limiting the number of messages
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Thu, 8 Oct 2009 07:52:42 -0400 (EDT)
  • References: <200910071102.HAA00467@smc.vnet.net>

Hi Sean,

To my mind, usage messages are needed mostly for those functions that you
are exporting to the user of your functionality. I beleive that the software
model where user's input checks are relegated to internal functions is
seriously flawed. For internal layers of a program (that is, for a
developer), I would use exceptions and stack traces, catching them in the
outer layers, possibly logging them,  and issuing error messages to the user
(possibly with a request for a bug report). At the end, errors happening
deep inside a program would indicate to me some flaw in the program rather
than in the user's input (which, I believe, should be checked by the public
functions exported to the user as properly and completely as possible), and
the user can  not be  supposed to examine a source (which may be even not
available to him/her) to find the reason for the wrong behavior.

I don't know any good way of making the procedure stop or abort its
evaluation upon some condition depending on evaluation of sub-procedures,
simply because the control has already been passed to sub-procedures
(perhaps  unless you use some form of non-local flow of control, such as
programming in continuation-passing style, which you probably don't).
Besides, a universal rule of aborting a function after some fixed number of
issued  error  messages is a rather ad hoc procedure - if you use stateful
programming (at least in part), your program  / system may end up in an
illegal state. However, exceptions (which also represent non-local control
flow) issued by sub-procedures in a controlled way, may effectively allow
you to do a similar thing to what you want.

Sorry if I wasn't exactly helpful.

Regards,
Leonid



On Wed, Oct 7, 2009 at 3:02 PM, Sean McConnell <
smcconne at physi.uni-heidelberg.de> wrote:

> Hi,
>
> I'm creating a program with procedures that often depend on
> sub-procedures. Many times I allow the sub-procedures to do the input
> checking, so I don't have to write a the same error trapping conditions
> and messages for each level of the program. The problem is however that
> although the 'input checking' is passed on to a sub-procedure, the main
> procedure continues to attempt to evaluate, and can usually return a
> very long list of error messages whilst it foolishly attempting to
> evaluate with improperly input variables.
>
> I would like to know how to make a procedure abort its evaluation after
> say 3 or so messages, and simply return the name of the procedure and
> the variables (as happens when you use /; for conditionals). I have
> tried the use of Check[], and although it checks for messages, it will
> only return what is typed in to the space for a second argument (eg:
> Check[f[a], "problem"] will return simply "problem"), I would like to be
> able to tell the user how they have screwed up.
>
> Many thanks,
>
> Sean McConnell.
>
>
>



  • Prev by Date: Re: confused about == vs === in this equality
  • Next by Date: Re: Re: generating submultisets with repeated elements
  • Previous by thread: Re: Limiting the number of messages
  • Next by thread: Re: Limiting the number of messages