Bug 14388 - seq.int evaluates its arguments twice, with twice the side effects
seq.int evaluates its arguments twice, with twice the side effects
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Language
R 2.12.0
All All
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-09-25 22:08 UTC by Radford Neal
Modified: 2010-10-04 09:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Radford Neal 2010-09-25 22:08:49 UTC
The "seq.int" primitive evaluates all its arguments twice, producing any side effects of the evaluation two times.  For example:

> f <- function (x) { print("f"); x }
> seq.int(1,f(5))
[1] "f"
[1] "f"
[1] 1 2 3 4 5
> seq.int(1,5,by=f(2))
[1] "f"
[1] "f"
[1] 1 3 5

This does not happen with "seq", which evaluates its arguments only once.
Comment 1 Brian Ripley 2010-10-01 16:27:42 UTC
A simple one-char typo!
Comment 2 Brian Ripley 2010-10-01 16:28:19 UTC
fixed for 2.12.0beta.
Comment 3 Brian Ripley 2010-10-01 16:37:52 UTC
But that fix isn't the whole story -- so looking again.
Comment 4 Brian Ripley 2010-10-04 09:50:15 UTC
This is fixed in R-devel, and will be ported for R 2.12.1.

The subtlety is how method dispatch is done, which was intended to
match seq().