Re: [Rd] comment causes browser() to exit (PR#9063)

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Fri 07 Jul 2006 - 14:26:24 GMT


If I'm not mistaken, this works as documented. As an example (typed directly into the Rgui console on WinXP):

R> f <- function() {

+     browser()
+     cat("I'm here!\n")
+     cat("I'm still here!\n")
+ }

R> f()
Called from: f()
Browse[1]> ## where to?
I'm here!
I'm still here!

which I think is what you saw. However:

R> f()
Called from: f()
Browse[1]> n
debug: cat("I'm here!\n")
Browse[1]> ##
I'm here!
debug: cat("I'm still here!\n")
Browse[1]>
I'm still here!

>From ?browser:

c
(or just return) exit the browser and continue execution at the next statement.
cont
synonym for c.
n
enter the step-through debugger. This changes the meaning of c: see the documentation for debug.

My interpretation of this is that, if the first thing typed (or pasted) in is something like a null statement (e.g., return, empty line, or comment), it's the same as 'c', but if the null statement follows 'n', then it behaves differently.

               _                         
platform       i386-pc-mingw32           
arch           i386                      
os             mingw32                   
system         i386, mingw32             
status                                   
major          2                         
minor          3.1                       
year           2006                      
month          06                        
day            01                        
svn rev        38247                     
language       R                         
version.string Version 2.3.1 (2006-06-01)

Andy

From: timh@insightful.com
>
> I'm trying to step through some code using browser(),
> executing one line at a time.
> Unfortunately, whenever I execute a comment line, the browser exits.
>
> I previously reported a similar problem with blank lines.
>
> These problems are a strong incentive to write poor code
> -- uncommented code with no blank lines to improve
> readability -- so that I can use browser() without it exiting
> at inconvenient times.
>
> Additional detail:
> (1) I'm running R inside emacs, with R in one buffer and a
> file containing code in another, using a macro to copy and
> paste a line at a time from the file to the R buffer.
> (2) The browser() call is inside a function.
> Right now the lines I'm sending to the browser are not part
> of the function, though usually they are.
>
>
> --please do not edit the information below--
>
> Version:
> platform = i386-pc-mingw32
> arch = i386
> os = mingw32
> system = i386, mingw32
> status =
> major = 2
> minor = 3.1
> year = 2006
> month = 06
> day = 01
> svn rev = 38247
> language = R
> version.string = Version 2.3.1 (2006-06-01)
>
> Windows XP Professional (build 2600) Service Pack 2.0
>
> Locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> Search Path:
> .GlobalEnv, package:methods, package:stats,
> package:graphics, package:grDevices, package:utils,
> package:datasets, Autoloads, package:base
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Jul 08 01:51:01 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 07 Jul 2006 - 18:31:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.