Re: [R-pkg-devel] Visible bindings and reference classes

2015-08-11 Thread Martin Maechler
 Colin Gillespie csgilles...@gmail.com
 on Mon, 10 Aug 2015 20:33:32 + writes:

 Dear All,
 
 I have a package that uses reference classes. When I build the package I
 get numerous notes of the sort
 
 Note: no visible binding for '-' assignment to 'pars'
 
 I've tried using GlobalVariables, but that didn't solve the issue.

[ You mean globalVariables(): and it's a bad idea anyway IMO, 
  even if it is recommended : If you declare a variable in
  there, it is global in all places in your package and the
  codetools won't report it anywhere anymore.
  Much better in my view is to use something like

  var7 - NULL # ~= globalVariables(var7)
 
]

To your question:

Reference classes are used in *many* places,  and the use of  ' - '
is really standard there.
e.g., package 'lme4', or 'pcalg' are two packages I'm involved with,
which use ref.classes and ' - '  but are fine with that.

So there must be something peculiar in your package leading to
the  -  warnings.

Maybe you should look into the source code of such other CRAN
packages to see how they do it differently than you.

Best regards,
Martin

Martin Maechler, ETH Zurich


 After some googling, I came across the page
 http://stackoverflow.com/q/23475309/203420 which suggests
 
 suppressBindingNotes - function(variablesMentionedInNotes) {
   for(variable in variablesMentionedInNotes) {
 assign(variable,NULL, envir = .GlobalEnv)
   }
 }
 suppressBindingNotes(c(dat, internal, xmin, pars, no_pars))
 
 But checking the package with --as-cran raises the note
 
 * checking R code for possible problems ... NOTE
 Found the following assignments to the global environment:
   File ‘poweRlaw/R/aaa_all_classes.R’:
   assign(variable, NULL, envir = .GlobalEnv)
 
 What is the correct way of removing the visible bindings notes?
 
 Thanks
 
 Colin
 
   [[alternative HTML version deleted]]
 
 __
 R-package-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-package-devel

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Visible bindings and reference classes

2015-08-11 Thread Colin Gillespie


 To your question:

 Reference classes are used in *many* places,  and the use of  ' - '
 is really standard there.
 e.g., package 'lme4', or 'pcalg' are two packages I'm involved with,
 which use ref.classes and ' - '  but are fine with that.

 So there must be something peculiar in your package leading to
 the  -  warnings.


After a bit more investigating I've narrowed it down.  The notes can be
generated by having

d1 = setRefClass(d1, fields=list(x = numeric))
d1$accessors(x)

**and** having ByteCompile: true. Commenting out the accessors line removes
the visible binding note. The  x=NULL  or globalVariables(x) trick
doesn't work.

A stackoverflow answer suggests that I need to add

assign(variable,NULL, envir = .GlobalEnv)

but this generates a new NOTE under R CMD check

I've not been able to find another package that uses accessors and
ByteCompile

Thanks

Colin











 Maybe you should look into the source code of such other CRAN
 packages to see how they do it differently than you.

 Best regards,
 Martin

 Martin Maechler, ETH Zurich


  After some googling, I came across the page
  http://stackoverflow.com/q/23475309/203420 which suggests
 
  suppressBindingNotes - function(variablesMentionedInNotes) {
for(variable in variablesMentionedInNotes) {
  assign(variable,NULL, envir = .GlobalEnv)
}
  }
  suppressBindingNotes(c(dat, internal, xmin, pars, no_pars))
 
  But checking the package with --as-cran raises the note
 
  * checking R code for possible problems ... NOTE
  Found the following assignments to the global environment:
File ‘poweRlaw/R/aaa_all_classes.R’:
assign(variable, NULL, envir = .GlobalEnv)
 
  What is the correct way of removing the visible bindings notes?
 
  Thanks
 
  Colin
 
[[alternative HTML version deleted]]
 
  __
  R-package-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-package-devel


[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Visible bindings and reference classes

2015-08-11 Thread William Dunlap
You can avoid the temporary file by replacing
  dput(def, file= (tf - tempfile()))
  compiler::cmpfile(tf)
with
  cdef - compiler::compile(def)
  #Note: no visible binding for '-' assignment to 'ConfigString'
The compiled code appears to work.
  eval(cdef)
  c1 - Config$new()
  c1
  #Reference class object of class Config
  #Field ConfigString:
  #[1] Hello, World!
   objects(all=TRUE)
  #[1] .__C__Config   .__global__
  #[3] .requireCachedGenerics c1
  #[5] cdef   Config
  #[7] def


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Aug 11, 2015 at 8:47 AM, William Dunlap wdun...@tibco.com wrote:

 This is a problem in the compiler package.  Here is a way to reproduce it:

 def - quote(Config - setRefClass(Config,
 fields = list(
 ConfigString = character),
 methods = list(
 # Constructor
 initialize = function() {
 ConfigString - Hello, World!
 })
 ))
 dput(def, file= (tf - tempfile()))
 compiler::cmpfile(tf)
 #Note: no visible binding for '-' assignment to 'ConfigString'
 saving to file
 #C:\Users\wdunlap\AppData\Local\Temp\Rtmpk91qvT\file26d447c45b81.Rc ...
 done




 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

 On Tue, Aug 11, 2015 at 4:24 AM, Martin Maechler 
 maech...@stat.math.ethz.ch wrote:

  Colin Gillespie csgilles...@gmail.com
  on Mon, 10 Aug 2015 20:33:32 + writes:

  Dear All,
 
  I have a package that uses reference classes. When I build the package I
  get numerous notes of the sort
 
  Note: no visible binding for '-' assignment to 'pars'
 
  I've tried using GlobalVariables, but that didn't solve the issue.

 [ You mean globalVariables(): and it's a bad idea anyway IMO,
   even if it is recommended : If you declare a variable in
   there, it is global in all places in your package and the
   codetools won't report it anywhere anymore.
   Much better in my view is to use something like

   var7 - NULL # ~= globalVariables(var7)

 ]

 To your question:

 Reference classes are used in *many* places,  and the use of  ' - '
 is really standard there.
 e.g., package 'lme4', or 'pcalg' are two packages I'm involved with,
 which use ref.classes and ' - '  but are fine with that.

 So there must be something peculiar in your package leading to
 the  -  warnings.

 Maybe you should look into the source code of such other CRAN
 packages to see how they do it differently than you.

 Best regards,
 Martin

 Martin Maechler, ETH Zurich


  After some googling, I came across the page
  http://stackoverflow.com/q/23475309/203420 which suggests
 
  suppressBindingNotes - function(variablesMentionedInNotes) {
for(variable in variablesMentionedInNotes) {
  assign(variable,NULL, envir = .GlobalEnv)
}
  }
  suppressBindingNotes(c(dat, internal, xmin, pars, no_pars))
 
  But checking the package with --as-cran raises the note
 
  * checking R code for possible problems ... NOTE
  Found the following assignments to the global environment:
File ‘poweRlaw/R/aaa_all_classes.R’:
assign(variable, NULL, envir = .GlobalEnv)
 
  What is the correct way of removing the visible bindings notes?
 
  Thanks
 
  Colin
 
[[alternative HTML version deleted]]
 
  __
  R-package-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-package-devel

 __
 R-package-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-package-devel




[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Visible bindings and reference classes

2015-08-11 Thread William Dunlap
This is a problem in the compiler package.  Here is a way to reproduce it:

def - quote(Config - setRefClass(Config,
fields = list(
ConfigString = character),
methods = list(
# Constructor
initialize = function() {
ConfigString - Hello, World!
})
))
dput(def, file= (tf - tempfile()))
compiler::cmpfile(tf)
#Note: no visible binding for '-' assignment to 'ConfigString'
saving to file
#C:\Users\wdunlap\AppData\Local\Temp\Rtmpk91qvT\file26d447c45b81.Rc ...
done




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Aug 11, 2015 at 4:24 AM, Martin Maechler maech...@stat.math.ethz.ch
 wrote:

  Colin Gillespie csgilles...@gmail.com
  on Mon, 10 Aug 2015 20:33:32 + writes:

  Dear All,
 
  I have a package that uses reference classes. When I build the package I
  get numerous notes of the sort
 
  Note: no visible binding for '-' assignment to 'pars'
 
  I've tried using GlobalVariables, but that didn't solve the issue.

 [ You mean globalVariables(): and it's a bad idea anyway IMO,
   even if it is recommended : If you declare a variable in
   there, it is global in all places in your package and the
   codetools won't report it anywhere anymore.
   Much better in my view is to use something like

   var7 - NULL # ~= globalVariables(var7)

 ]

 To your question:

 Reference classes are used in *many* places,  and the use of  ' - '
 is really standard there.
 e.g., package 'lme4', or 'pcalg' are two packages I'm involved with,
 which use ref.classes and ' - '  but are fine with that.

 So there must be something peculiar in your package leading to
 the  -  warnings.

 Maybe you should look into the source code of such other CRAN
 packages to see how they do it differently than you.

 Best regards,
 Martin

 Martin Maechler, ETH Zurich


  After some googling, I came across the page
  http://stackoverflow.com/q/23475309/203420 which suggests
 
  suppressBindingNotes - function(variablesMentionedInNotes) {
for(variable in variablesMentionedInNotes) {
  assign(variable,NULL, envir = .GlobalEnv)
}
  }
  suppressBindingNotes(c(dat, internal, xmin, pars, no_pars))
 
  But checking the package with --as-cran raises the note
 
  * checking R code for possible problems ... NOTE
  Found the following assignments to the global environment:
File ‘poweRlaw/R/aaa_all_classes.R’:
assign(variable, NULL, envir = .GlobalEnv)
 
  What is the correct way of removing the visible bindings notes?
 
  Thanks
 
  Colin
 
[[alternative HTML version deleted]]
 
  __
  R-package-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-package-devel

 __
 R-package-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-package-devel


[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Visible bindings and reference classes

2015-08-10 Thread Colin Gillespie
Dear All,

I have a package that uses reference classes. When I build the package I
get numerous notes of the sort

Note: no visible binding for '-' assignment to 'pars'

I've tried using GlobalVariables, but that didn't solve the issue.

After some googling, I came across the page
http://stackoverflow.com/q/23475309/203420 which suggests

suppressBindingNotes - function(variablesMentionedInNotes) {
  for(variable in variablesMentionedInNotes) {
assign(variable,NULL, envir = .GlobalEnv)
  }
}
suppressBindingNotes(c(dat, internal, xmin, pars, no_pars))

But checking the package with --as-cran raises the note

* checking R code for possible problems ... NOTE
Found the following assignments to the global environment:
  File ‘poweRlaw/R/aaa_all_classes.R’:
  assign(variable, NULL, envir = .GlobalEnv)

What is the correct way of removing the visible bindings notes?

Thanks

Colin

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel