[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-devel
Subject:    Re: [Rd] how to start local scope?
From:       Duncan Murdoch <murdoch () stats ! uwo ! ca>
Date:       2006-07-27 12:34:10
Message-ID: 44C8B2C2.5010104 () stats ! uwo ! ca
[Download RAW message or body]

On 7/27/2006 8:16 AM, Tamas K Papp wrote:
> How can I start a local scope inside an R function?  Eg in
> 
>> b
> Error: object "b" not found
>> f <- function() {
> +   {
> +     b <- 1
> +   }
> +   b+2
> + }
>> f()
> [1] 3
> 
> I would like f() to report an error, not finding b.  I am thinking
> about something like let in Scheme/Lisp.

The local() function does this:

 > f <- function() {
+   local({ b <- 1 })
+   b + 2
+ }
 > f()
Error in f() : object "b" not found

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic