From Martin Maechler <maechler@stat.math.ethz.ch>  Thu Jan 22 11:02:36 1998
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Thu, 22 Jan 1998 12:02:36 +0100
Subject: Re^2: R feature request:  stop(..) should print its caller call
In-Reply-To: <199801221007.LAA21175@pc25.none> (message from Kurt Hornik on
 Thu, 22 Jan 1998 11:07:45 +0100)
Message-ID: <199801221102.MAA09835@sophie.ethz.ch>


>>>>> "KH" == Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:

>>>>> Martin Maechler writes:

    >> The following shows what I mean:
    >> tst<-function(x)in.tst(x); in.tst<-function(y)stop(paste("y is",y)); tst(pi)

    >> in R gives

    >> --------------------
    >> Error: y is 3.141593
    >> --------------------

    >> in S-plus gives

    >> ----------------------------------------
    >>> > Error in in.tst(x): y is 3.14159265358979
    >> Dumped    ^^^^^^^^^^^^
    >> ----------------------------------------

    >> For locating bugs / problems in functions, it would be tremendously
    >> helpful if R also printed the name of the function from which it is
    >> called (actually the ``call(..)'' rather than just the function name).

    KH> Martin,

    KH> I am not sure.  I find it more useful to call traceback() after an error
    KH> occurred to find out what really happened.

The existence of a good utility such as traceback() 
should not prevent  stop(..) from producing more informative output.

The reason I think this is really wanted:

Many S- and R- function  composers try to write functions which 
``behave'', i.e. produce reasonable error messages when they are called
with "bad" arguments.

If I (as a function composer) 
think on how to fill the "...." in a  stop(....),
I've always been assuming that stop() would prepend the call (i.e. at least
the calling function).

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Re^2: R feature request: stop(..) should print its caller call
Martin Maechler