[6329] in s-news-athena
Quitting S
daemon@ATHENA.MIT.EDU (Russ Lenth)
Tue Jan 31 12:29:33 1995
Date: Tue, 31 Jan 95 10:50:24 CST
From: rlenth@stat.uiowa.edu (Russ Lenth)
To: s-news@utstat.toronto.edu
There has been some discussion of user-friendliness. One of my first
impressions of S was an unfavorable one: there being no obvious
way to get out.
I realize, and advise others, that first thing to learn about a new
program is how to get out of it, and the second thing is how to start
it; alas, I don't always follow my own advice.
Given my learning experience, the first assignment statement I ask
students to enter in S is:
quit <- "To quit, type 'q()'"
Subsequently, if they try to exit the program by typing "quit",
they at least get reminded of how to quit.
It seems to me that one ought to be able to exit any command-driven
application by typing a word like "stop", "quit", or "exit", and it
is irritating that S and S-Plus don't provide a discoverable way out.
However, this problem is easily fixed, and the solution is an
interesting, simple lesson in object-oriented programming...
quit <- NULL
class(quit) <- "QUIT"
print.QUIT <- function(...)
if ( menu(c("Quit S", "Continue")) == 1 ) q()
QUIT <- stop <- STOP <- quit
Now, if one types "quit" or "stop" in either upper or lower case, the
print method for objects of class "QUIT" is invoked. This particular
implementation provides a chance to bail out.
Using a similar method, one can obtain help by typing "help" - However,
there is also a warning message due to having a function of the same
name.
------------------------------------------------ --------------,
Russ Lenth rlenth@stat.uiowa.edu \ )
Department of Statistics | \_ "The Athens
and Actuarial Science Tel: (319)335-0814 \ Iowa City \ of the
The University of Iowa FAX: (319)335-3017 \ * _/ Midwest"
Iowa City, IA 52242 USA CW: *= * ====== *=* | /
------------------------------------------------ ----------v