[Rd] Compiler + stopifnot bug

2019-01-03 Thread Iñaki Ucar
Hi,

I found the following issue in r-devel (2019-01-02 r75945):

`foo<-` <- function(x, value) {
  bar(x) <- value * x
  x
}

`bar<-` <- function(x, value) {
  stopifnot(all(value / x == 1))
  x + value
}

`foo<-` <- compiler::cmpfun(`foo<-`)
`bar<-` <- compiler::cmpfun(`bar<-`)

x <- c(2, 2)
foo(x) <- 1
x # should be c(4, 4)
#> [1] 3 3

If the functions are not compiled or the stopifnot call is removed,
the snippet works correctly. So it seems that something is messing
around with the references to "value" when the call to stopifnot gets
compiled, and the wrong "value" is modified. Note also that if "x <-
2", then the result is correct, 4.

Regards,
-- 
Iñaki Úcar

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


Re: [Rd] Compiler + stopifnot bug

2019-01-03 Thread Duncan Murdoch

I see this too; by bisection, it seems to have first appeared in r72943.

Duncan Murdoch

On 03/01/2019 2:18 p.m., Iñaki Ucar wrote:

Hi,

I found the following issue in r-devel (2019-01-02 r75945):

`foo<-` <- function(x, value) {
   bar(x) <- value * x
   x
}

`bar<-` <- function(x, value) {
   stopifnot(all(value / x == 1))
   x + value
}

`foo<-` <- compiler::cmpfun(`foo<-`)
`bar<-` <- compiler::cmpfun(`bar<-`)

x <- c(2, 2)
foo(x) <- 1
x # should be c(4, 4)
#> [1] 3 3

If the functions are not compiled or the stopifnot call is removed,
the snippet works correctly. So it seems that something is messing
around with the references to "value" when the call to stopifnot gets
compiled, and the wrong "value" is modified. Note also that if "x <-
2", then the result is correct, 4.

Regards,



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


[Rd] history of objects() and ls()

2019-01-03 Thread Ben Bolker


  I found out today (maybe I had known sometime before??) that objects()
is a synonym for ls().  I'm curious about the history, which seems to go
at least back to the beginning of R.  It's been thus since SVN revision
2 (Sep 1997) ...

svn cat https://svn.r-project.org/R/trunk/src/library/base/R/attach@2 |
grep objects

  I had a quick look at the Becker & Chambers brown book (1984) and
Becker and Wilks blue book (1988) on Google books and could find ls but
not objects() ... ?

  Anyone happen to know?

 cheers
   Ben Bolker

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


Re: [Rd] Compiler + stopifnot bug

2019-01-03 Thread Duncan Murdoch

On 03/01/2019 3:37 p.m., Duncan Murdoch wrote:

I see this too; by bisection, it seems to have first appeared in r72943.


Sorry, that was a typo.  I meant r75943.

Duncan Murdoch



Duncan Murdoch

On 03/01/2019 2:18 p.m., Iñaki Ucar wrote:

Hi,

I found the following issue in r-devel (2019-01-02 r75945):

`foo<-` <- function(x, value) {
bar(x) <- value * x
x
}

`bar<-` <- function(x, value) {
stopifnot(all(value / x == 1))
x + value
}

`foo<-` <- compiler::cmpfun(`foo<-`)
`bar<-` <- compiler::cmpfun(`bar<-`)

x <- c(2, 2)
foo(x) <- 1
x # should be c(4, 4)
#> [1] 3 3

If the functions are not compiled or the stopifnot call is removed,
the snippet works correctly. So it seems that something is messing
around with the references to "value" when the call to stopifnot gets
compiled, and the wrong "value" is modified. Note also that if "x <-
2", then the result is correct, 4.

Regards,





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


Re: [Rd] Compiler + stopifnot bug

2019-01-03 Thread Martin Morgan
For what it's worth this also introduced

> df = data.frame(v = package_version("1.2"))
> rbind(df, df)$v
 [[1]]
 [1] 1 2

 [[2]]
 [1] 1 2

instead of

> rbind(df, df)$v
[1] '1.2' '1.2'

which shows up in Travis builds of Bioconductor packages

  https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014506.html

and elsewhere

Martin Morgan

On 1/3/19, 7:05 PM, "R-devel on behalf of Duncan Murdoch" 
 wrote:

On 03/01/2019 3:37 p.m., Duncan Murdoch wrote:
> I see this too; by bisection, it seems to have first appeared in r72943.

Sorry, that was a typo.  I meant r75943.

Duncan Murdoch

> 
> Duncan Murdoch
> 
> On 03/01/2019 2:18 p.m., Iñaki Ucar wrote:
>> Hi,
>>
>> I found the following issue in r-devel (2019-01-02 r75945):
>>
>> `foo<-` <- function(x, value) {
>> bar(x) <- value * x
>> x
>> }
>>
>> `bar<-` <- function(x, value) {
>> stopifnot(all(value / x == 1))
>> x + value
>> }
>>
>> `foo<-` <- compiler::cmpfun(`foo<-`)
>> `bar<-` <- compiler::cmpfun(`bar<-`)
>>
>> x <- c(2, 2)
>> foo(x) <- 1
>> x # should be c(4, 4)
>> #> [1] 3 3
>>
>> If the functions are not compiled or the stopifnot call is removed,
>> the snippet works correctly. So it seems that something is messing
>> around with the references to "value" when the call to stopifnot gets
>> compiled, and the wrong "value" is modified. Note also that if "x <-
>> 2", then the result is correct, 4.
>>
>> Regards,
>>
>

__
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


Re: [Rd] Compiler + stopifnot bug

2019-01-03 Thread Tierney, Luke
Thanks for the reports. Will look into it soon and report back.

Luke

Sent from my iPhone

> On Jan 3, 2019, at 2:15 PM, Martin Morgan  wrote:
> 
> For what it's worth this also introduced
> 
>> df = data.frame(v = package_version("1.2"))
>> rbind(df, df)$v
> [[1]]
> [1] 1 2
> 
> [[2]]
> [1] 1 2
> 
> instead of
> 
>> rbind(df, df)$v
>[1] '1.2' '1.2'
> 
> which shows up in Travis builds of Bioconductor packages
> 
>  https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014506.html
> 
> and elsewhere
> 
> Martin Morgan
> 
> On 1/3/19, 7:05 PM, "R-devel on behalf of Duncan Murdoch" 
>  wrote:
> 
>>On 03/01/2019 3:37 p.m., Duncan Murdoch wrote:
>> I see this too; by bisection, it seems to have first appeared in r72943.
> 
>Sorry, that was a typo.  I meant r75943.
> 
>Duncan Murdoch
> 
>> 
>> Duncan Murdoch
>> 
>>> On 03/01/2019 2:18 p.m., Iñaki Ucar wrote:
>>> Hi,
>>> 
>>> I found the following issue in r-devel (2019-01-02 r75945):
>>> 
>>> `foo<-` <- function(x, value) {
>>>bar(x) <- value * x
>>>x
>>> }
>>> 
>>> `bar<-` <- function(x, value) {
>>>stopifnot(all(value / x == 1))
>>>x + value
>>> }
>>> 
>>> `foo<-` <- compiler::cmpfun(`foo<-`)
>>> `bar<-` <- compiler::cmpfun(`bar<-`)
>>> 
>>> x <- c(2, 2)
>>> foo(x) <- 1
>>> x # should be c(4, 4)
>>> #> [1] 3 3
>>> 
>>> If the functions are not compiled or the stopifnot call is removed,
>>> the snippet works correctly. So it seems that something is messing
>>> around with the references to "value" when the call to stopifnot gets
>>> compiled, and the wrong "value" is modified. Note also that if "x <-
>>> 2", then the result is correct, 4.
>>> 
>>> Regards,
>>> 
>> 
> 
>__
>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
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] history of objects() and ls()

2019-01-03 Thread Peter Dalgaard
As far as I remember, this comes from S-PLUS, introduced around v.3 (white 
book?) or maybe v.4, and due to a desire to cut some Unix ties as MS-DOS was 
taking over the world. However, it was long ago, in a different world, and 
besides, S-PLUS is dead (mostly).

- Peter 

> On 4 Jan 2019, at 00:45 , Ben Bolker  wrote:
> 
> 
>  I found out today (maybe I had known sometime before??) that objects()
> is a synonym for ls().  I'm curious about the history, which seems to go
> at least back to the beginning of R.  It's been thus since SVN revision
> 2 (Sep 1997) ...
> 
> svn cat https://svn.r-project.org/R/trunk/src/library/base/R/attach@2 |
> grep objects
> 
>  I had a quick look at the Becker & Chambers brown book (1984) and
> Becker and Wilks blue book (1988) on Google books and could find ls but
> not objects() ... ?
> 
>  Anyone happen to know?
> 
> cheers
>   Ben Bolker
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [Rd] history of objects() and ls()

2019-01-03 Thread William Dunlap via R-devel
S-PLUS took it from S, sometime in the early 1990's.  The "White Book"
("Statistical Models in S", Chambers and Hastie, eds.,1992), uses objects()
on p.88..

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Jan 3, 2019 at 4:47 PM Peter Dalgaard  wrote:

> As far as I remember, this comes from S-PLUS, introduced around v.3 (white
> book?) or maybe v.4, and due to a desire to cut some Unix ties as MS-DOS
> was taking over the world. However, it was long ago, in a different world,
> and besides, S-PLUS is dead (mostly).
>
> - Peter
>
> > On 4 Jan 2019, at 00:45 , Ben Bolker  wrote:
> >
> >
> >  I found out today (maybe I had known sometime before??) that objects()
> > is a synonym for ls().  I'm curious about the history, which seems to go
> > at least back to the beginning of R.  It's been thus since SVN revision
> > 2 (Sep 1997) ...
> >
> > svn cat https://svn.r-project.org/R/trunk/src/library/base/R/attach@2 |
> > grep objects
> >
> >  I had a quick look at the Becker & Chambers brown book (1984) and
> > Becker and Wilks blue book (1988) on Google books and could find ls but
> > not objects() ... ?
> >
> >  Anyone happen to know?
> >
> > cheers
> >   Ben Bolker
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

[[alternative HTML version deleted]]

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


Re: [Rd] Compiler + stopifnot bug

2019-01-03 Thread Tierney, Luke
Should be fixed in r75946.

Best,

luke

On Fri, 4 Jan 2019, Tierney, Luke wrote:

> Thanks for the reports. Will look into it soon and report back.
>
> Luke
>
> Sent from my iPhone
>
>> On Jan 3, 2019, at 2:15 PM, Martin Morgan  wrote:
>>
>> For what it's worth this also introduced
>>
>>> df = data.frame(v = package_version("1.2"))
>>> rbind(df, df)$v
>> [[1]]
>> [1] 1 2
>>
>> [[2]]
>> [1] 1 2
>>
>> instead of
>>
>>> rbind(df, df)$v
>>[1] '1.2' '1.2'
>>
>> which shows up in Travis builds of Bioconductor packages
>>
>>  https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014506.html
>>
>> and elsewhere
>>
>> Martin Morgan
>>
>> On 1/3/19, 7:05 PM, "R-devel on behalf of Duncan Murdoch" 
>>  wrote:
>>
>>>On 03/01/2019 3:37 p.m., Duncan Murdoch wrote:
>>> I see this too; by bisection, it seems to have first appeared in r72943.
>>
>>Sorry, that was a typo.  I meant r75943.
>>
>>Duncan Murdoch
>>
>>>
>>> Duncan Murdoch
>>>
 On 03/01/2019 2:18 p.m., Iñaki Ucar wrote:
 Hi,

 I found the following issue in r-devel (2019-01-02 r75945):

 `foo<-` <- function(x, value) {
bar(x) <- value * x
x
 }

 `bar<-` <- function(x, value) {
stopifnot(all(value / x == 1))
x + value
 }

 `foo<-` <- compiler::cmpfun(`foo<-`)
 `bar<-` <- compiler::cmpfun(`bar<-`)

 x <- c(2, 2)
 foo(x) <- 1
 x # should be c(4, 4)
 #> [1] 3 3

 If the functions are not compiled or the stopifnot call is removed,
 the snippet works correctly. So it seems that something is messing
 around with the references to "value" when the call to stopifnot gets
 compiled, and the wrong "value" is modified. Note also that if "x <-
 2", then the result is correct, 4.

 Regards,

>>>
>>
>>__
>>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
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
Actuarial Science
241 Schaeffer Hall  email:   luke-tier...@uiowa.edu
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel