The R Project SVN R

Rev

Rev 23710 | Rev 40615 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23710 Rev 29688
Line 49... Line 49...
49
  and variables linked to data bases to be implemented.  It may also
49
  and variables linked to data bases to be implemented.  It may also
50
  be useful for making thread-safe versions of some system globals.
50
  be useful for making thread-safe versions of some system globals.
51
}
51
}
52
\examples{
52
\examples{
53
# locking environments
53
# locking environments
54
e<-new.env()
54
e <- new.env()
55
assign("x",1, env=e)
55
assign("x", 1, env = e)
56
get("x",env=e)
56
get("x", env = e)
57
lockEnvironment(e)
57
lockEnvironment(e)
58
get("x",env=e)
58
get("x", env = e)
59
assign("x",2, env=e)
59
assign("x", 2, env = e)
60
try(assign("y",2, env=e)) # error
60
try(assign("y", 2, env = e)) # error
61
 
61
 
62
# locking bindings
62
# locking bindings
63
e<-new.env()
63
e <- new.env()
64
assign("x",1, env=e)
64
assign("x", 1, env = e)
65
get("x",env=e)
65
get("x", env = e)
66
lockBinding("x", e)
66
lockBinding("x", e)
67
try(assign("x",2, env=e)) # error
67
try(assign("x", 2, env = e)) # error
68
unlockBinding("x", e)
68
unlockBinding("x", e)
69
assign("x",2, env=e)
69
assign("x", 2, env = e)
70
get("x",env=e)
70
get("x", env = e)
71
 
71
 
72
# active bindings
72
# active bindings
73
f<-local({
73
f <- local( {
74
    x <- 1
74
    x <- 1
75
    function(v) {
75
    function(v) {
76
       if (missing(v))
76
       if (missing(v))
77
           cat("get\n")
77
           cat("get\n")
78
       else {
78
       else {
Line 83... Line 83...
83
    }
83
    }
84
})
84
})
85
makeActiveBinding("fred", f, .GlobalEnv)
85
makeActiveBinding("fred", f, .GlobalEnv)
86
bindingIsActive("fred", .GlobalEnv)
86
bindingIsActive("fred", .GlobalEnv)
87
fred
87
fred
88
fred<-2
88
fred <- 2
89
fred
89
fred
90
}
90
}
91
\keyword{internal}
91
\keyword{internal}
92
\author{Luke Tierney}
92
\author{Luke Tierney}