Re: [Rd] Bug in perl=TRUE regexp matching?

2023-07-24 Thread Brodie Gaslam via R-devel
On 7/24/23 4:10 AM, Duncan Murdoch wrote: On 23/07/2023 9:01 p.m., Brodie Gaslam wrote: On 7/23/23 4:29 PM, Duncan Murdoch wrote: The help page for `?gsub` says (in the context of performance considerations): "... just one UTF-8 string will force all the matching to be done in Unicode"

Re: [Rd] Bug in perl=TRUE regexp matching?

2023-07-23 Thread Brodie Gaslam via R-devel
On 7/23/23 4:29 PM, Duncan Murdoch wrote: The help page for `?gsub` says (in the context of performance considerations): "... just one UTF-8 string will force all the matching to be done in Unicode" It's been a little while since I looked at the code but IIRC this just means that string

Re: [Rd] Bug in optim for specific orders of magnitude

2022-12-26 Thread Brodie Gaslam via R-devel
FWIW, I suspect the problem might have something to do with: > 1/1e-308 [1] 1e+308 > 1/1e-309 [1] Inf > 1e-309 > 0 [1] TRUE > 1e-324 > 0 [1] FALSE That is 1e-309 starts being treated as zero by division, but not by comparison (which happens at 1e-324).  This is not quite the range of values you

Re: [Rd] parent.frame(n) produces different result from sys.frame(sys.parent(n))

2022-09-28 Thread Brodie Gaslam via R-devel
Hi Taras, I have not looked in detail at your examples here, but the use of evalq and sys.parent makes me think these issues: https://bugs.r-project.org/show_bug.cgi?id=17849 https://bugs.r-project.org/show_bug.cgi?id=15531 are possibly related. Best, B. On Wednesday, September 28, 2022 at

Re: [Rd] gsub() hex character range problems in R-devel?

2022-01-04 Thread Brodie Gaslam via R-devel
> On Tuesday, January 4, 2022, 02:35:50 PM EST, Martin Morgan > wrote: > > I'm not very good at character encoding / etc so this might be user > error. The following code is meant to replace extended ASCII characters, > in particular a non-breaking space, with "", and it works in > R-4-1-branch

Re: [Rd] [External] Re: Workaround very slow NAN/Infinities arithmetic?

2021-10-01 Thread Brodie Gaslam via R-devel
> On Thursday, September 30, 2021, 01:25:02 PM EDT, > wrote: > >> On Thu, 30 Sep 2021, brodie gaslam via R-devel wrote: >> >> André, >> >> I'm not an R core member, but happen to have looked a little bit at this >> issue myself.  I've se

Re: [Rd] Workaround very slow NAN/Infinities arithmetic?

2021-09-30 Thread brodie gaslam via R-devel
André, I'm not an R core member, but happen to have looked a little bit at this issue myself.  I've seen similar things on Skylake and Coffee Lake 2 (9700, one generation past your latest) too.  I think it would make sense to have some handling of this, although I would want to show the trade-of

Re: [Rd] Spurious warnings in coercion from double/complex/character to raw

2021-09-10 Thread brodie gaslam via R-devel
> On Friday, September 10, 2021, 03:13:54 PM EDT, Hervé Pagès > wrote: > > Good catch, thanks! > > Replacing > > if(ISNAN(vi) || (tmp = (int) vi) < 0 || tmp > 255) { > tmp = 0; > > warn |= WARN_RAW; > > } > pa[i] = (Rbyte) tmp; > > with > > if(ISNAN(vi) || vi <=

Re: [Rd] Should last default to .Machine$integer.max-1 for substring()

2021-06-20 Thread brodie gaslam via R-devel
> On Sunday, June 20, 2021, 9:29:28 PM EDT, brodie gaslam via R-devel > wrote: > >> On Sunday, June 20, 2021, 6:21:22 PM EDT, Michael Chirico >> wrote: >> >> The max width of a string is .Machine$integer.max-1: > > I think the max width is .Machine$integ

Re: [Rd] Should last default to .Machine$integer.max-1 for substring()

2021-06-20 Thread brodie gaslam via R-devel
> On Sunday, June 20, 2021, 6:21:22 PM EDT, Michael Chirico > wrote: > > Currently, substring defaults to last=100L, which strongly > suggests the intent is to default to "nchar(x)" without having to > compute/allocate that up front. > > Unfortunately, this default makes no sense for "very

Re: [Rd] How to get utf8 string using R externals

2021-06-02 Thread brodie gaslam via R-devel
> On Wednesday, June 2, 2021, 7:58:54 PM EDT, xiaoyan yu > wrote: > > I am using gmail. Not sure of the configuration of plain text. > The memory pointed by the char * as the output of Rf_translateChar() is > actually the string "". Hi Xiaoyan, Unfortunately I'm not super familiar with R on W

Re: [Rd] 1954 from NA

2021-05-23 Thread brodie gaslam via R-devel
> On Sunday, May 23, 2021, 10:45:22 AM EDT, Adrian Dușa > wrote: > > On Sun, May 23, 2021 at 4:33 PM brodie gaslam via R-devel > wrote: > > I should add, I don't know that you can rely on this > > particular encoding of R's NA.  If I were trying to restor

Re: [Rd] 1954 from NA

2021-05-23 Thread brodie gaslam via R-devel
Best, B. On Sunday, May 23, 2021, 9:23:54 AM EDT, brodie gaslam via R-devel wrote: This is because the NA in question is NA_real_, which is encoded in double precision IEEE-754, which uses 64 bits.  The "1954" is just part of the NA.  The NA must also conform to the NaN enco

Re: [Rd] 1954 from NA

2021-05-23 Thread brodie gaslam via R-devel
This is because the NA in question is NA_real_, which is encoded in double precision IEEE-754, which uses 64 bits.  The "1954" is just part of the NA.  The NA must also conform to the NaN encoding for double precision numbers, which requires that the "beginning" portion of the number be "0x7ff0" (w

Re: [Rd] Difference in NA behavior in R-devel running under valgrind

2021-04-29 Thread brodie gaslam via R-devel
-linux-gnu (64-bit) On Thursday, April 29, 2021, 8:40:21 PM EDT, brodie gaslam via R-devel wrote: > On Thursday, April 29, 2021, 6:35:16 PM EDT, Winston Chang > wrote: > Just to be clear, the RD binary that Jon used was NOT compiled with > Valgrind level 2 instrumentation. In hi

Re: [Rd] Difference in NA behavior in R-devel running under valgrind

2021-04-29 Thread brodie gaslam via R-devel
> On Thursday, April 29, 2021, 6:35:16 PM EDT, Winston Chang > wrote: > Just to be clear, the RD binary that Jon used was NOT compiled with > Valgrind level 2 instrumentation. In his example, however, he did run it > with valgrind, as in: > > # RD -d valgrind --quiet -e "sum(c(1, NA))" > ... >

Re: [Rd] Difference in NA behavior in R-devel running under valgrind

2021-04-29 Thread brodie gaslam via R-devel
NA propagation is complicated.  I don't know whether what you observe could be explained by the difference between a valgrind instrumented vs. not version of R (I gather the release version you used is not instrumented / possibly compiled differently too from the github issue?). Hopefully someone

Re: [Rd] as.list fails on functions with S3 classes

2021-04-28 Thread brodie gaslam via R-devel
> On Wednesday, April 28, 2021, 5:16:20 PM EDT, Gabriel Becker > wrote: > > Hi Antoine, > > I would say this is the correct behavior. S3 dispatch is solely (so far as > I know?) concerned with the "actual classes" on the object. This is because > S3 classes act as labels that inform dispatch wh

Re: [Rd] R crashes when using huge data sets with character string variables

2020-12-12 Thread brodie gaslam via R-devel
> On Saturday, December 12, 2020, 6:33:33 PM EST, Ben Bolker > wrote: > >  On Windows you can use memory.limit. > > https://stackoverflow.com/questions/12582793/limiting-memory-usage-in-r-under-linux > >    Not sure how much that helps. > >On 12/12/20 6:19 PM, Arne Henningsen wrote: >> When wor

Re: [Rd] sys.call() 's srcref doesn't match the language

2020-09-02 Thread brodie gaslam via R-devel
>On Wednesday, September 2, 2020, 6:19:20 PM EDT, Lionel Henry > wrote: > >Hello, > >The source references are useful for debugging tools because they >allow linking to call sites in the source files. > >I agree the output can be confusing. Perhaps this could be fixed by >tweaking the print method

[Rd] eval and Calling Frames

2020-05-31 Thread brodie gaslam via R-devel
I ran into an interesting issue with `evalq` (and also `eval(quote(...))`): f <- function() {    list( sys.parent(1), evalq(sys.parent(1)), evalq((function() sys.parent(2))()),  # add an anon fun layer evalq((function() sys.parent(1))())    )

[Rd] R-ints context documentation

2020-05-26 Thread brodie gaslam via R-devel
In 1.4 Contexts[1], should the following: > Note that whilst calls to closures and builtins set a context, > those to special internal functions never do. Be something like: > Note that whilst calls to closures always set a context, > those to builtins only set a context under profiling > or if

Re: [Rd] paste(character(0), collapse="", recycle0=FALSE) should be ""

2020-05-22 Thread brodie gaslam via R-devel
> On Friday, May 22, 2020, 6:16:45 PM EDT, Hervé Pagès > wrote: > > Gabe, > > It's the current behavior of paste() that is a major source of bugs: > >   ## Add "rs" prefix to SNP ids and collapse them in a >   ## comma-separated string. >   collapse_snp_ids <- function(snp_ids) >   paste("rs"

Re: [Rd] Precision of function mean,bug?

2020-05-20 Thread brodie gaslam via R-devel
> On Wednesday, May 20, 2020, 7:00:09 AM EDT, peter dalgaard > wrote: > > Expected, see FAQ 7.31. > > You just can't trust == on FP operations. Notice also Additionally, since you're implementing a "mean" function you are testing against R's mean, you might want to consider that R uses a two-p

Re: [Rd] edit() doubles backslashes when keep.source=TRUE

2020-05-15 Thread brodie gaslam via R-devel
> On Friday, May 15, 2020, 12:13:04 PM EDT, Dirk Eddelbuettel > wrote: > On 15 May 2020 at 15:41, Martin Maechler wrote: > | > | > |    Why does nobody anymore  help R development by working with > |    "R-devel", or at least then the alpha, beta and the "RC" > |    (Release Candidate) version

Re: [Rd] Minor Infelicity in Printing of Objects Nested in Lists

2020-05-10 Thread brodie gaslam via R-devel
est in addressing this. Best, B. >On 5/10/20, brodie gaslam via R-devel wrote: >> Currently S3 objects nested in generic vectors cause the tag buffer to be >> reset.  This feels sub-optimal for those objects that don't have a print >> method: >> >>> li

[Rd] Minor Infelicity in Printing of Objects Nested in Lists

2020-05-10 Thread brodie gaslam via R-devel
Currently S3 objects nested in generic vectors cause the tag buffer to be reset.  This feels sub-optimal for those objects that don't have a print method: > list(a=list(b='hello')) $a $a$b ### notice "$a$b" [1] "hello" > list(a=structure(list(b='hello'), class='world')) $a

[Rd] Character Column-width Calculations

2020-05-03 Thread brodie gaslam via R-devel
I just submitted a patch on bugzilla[1] to update the internal column-width tables to a more recent version of Unicode.  The most obvious way this shows up is with emoji now having a computed width of 2 columns instead of 1 once the patch is applied: > nchar('\U0001F600', type='width'). # grinn

[Rd] Possible Bug In Validation of UTF-8 Sequences

2020-04-04 Thread brodie gaslam via R-devel
As per `?intToUtf8`, and in the comments to `valid_utf8`[1], R intends to prevent illegal UTF-8 such as UTF-8 encoded UTF-16 surrogate pairs.  `R_nchar`, invoked via `base::nchar`, explicitly validates UTF-8 strings[2], but allows the surrogate:     > Encoding('\ud800')     [1] "UTF-8"     > ncha

Re: [Rd] findInterval Documentation Suggestion

2020-03-06 Thread brodie gaslam via R-devel
> On Friday, March 6, 2020, 8:56:54 AM EST, Martin Maechler > wrote: > Note that the  * -> LaTex -> PDF rendered version looks a bitnicer. Ah yes, that does indeed look quite a bit nicer. > I wrote the function and that help page originally. And thank you for doing so. It is a wonderful fu

Re: [Rd] findInterval Documentation Suggestion

2020-03-05 Thread brodie gaslam via R-devel
Trying the attachment as .txt instead of Rd. On Thursday, March 5, 2020, 5:20:25 PM EST, brodie gaslam via R-devel wrote: % File src/library/base/man/findInterval.Rd % Part of the R package, https://www.R-project.org % Copyright 1995-2020 R Core Team % Distributed under GPL 2 or later

[Rd] findInterval Documentation Suggestion

2020-03-05 Thread brodie gaslam via R-devel
I've found over time that R documentation that comes off as terse at first blush is usually revealed to be precise, concise, and complete on close reading.  I'm sure this is also true of `?findInterval`, but for whatever reason my brain simply refuses to extract meaning from it. Part of the proble

Re: [Rd] survival bug? - solved

2020-03-05 Thread brodie gaslam via R-devel
I _think_ the relevant section of the C standard is 6.5.6 Additive Operators Par 8, excerpted here: > If both the pointer operand and the result point to elements > of the same array object, or one past the last element of the > array object, the evaluation shall not produce an overflow; > oth

Re: [Rd] Another wish (?) for R 4.0.0: print(*, width = )

2020-01-07 Thread brodie gaslam via R-devel
For whatever my 2c are worth I think this would be nice.  I'm still uncomfortable at having to call `options` in my package `diffobj` to set output width. And since the topic is here, what about `show`?  Feels like it should accept `...` so that it too could be given some set of standard or no

Re: [Rd] [External] Mitigating Stalls Caused by Call Deparse on Error

2019-07-16 Thread brodie gaslam via R-devel
; Best, >> >> Brodie. >> >> [1]: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17580 >> >> On Sunday, July 14, 2019, 8:52:45 AM EDT, Tierney, Luke >> wrote: >> >> >> >> >> >> This is probably best viewed in

Re: [Rd] [External] Mitigating Stalls Caused by Call Deparse on Error

2019-07-14 Thread brodie gaslam via R-devel
n-standard evaluation contexts. Might be good to move to a wishlist item in bugzilla. Best, luke On Sat, 13 Jul 2019, brodie gaslam via R-devel wrote: > When large calls cause errors R may stall for extended periods.  This > is particularly likely to happen with `do.call`, as in this exa

Re: [Rd] strange increase in the reference number

2019-07-13 Thread brodie gaslam via R-devel
Re ENSURE_NAMEDMAX, I am unsure but think this happens in (src/eval.c@492): static SEXP forcePromise(SEXP e) {     if (PRVALUE(e) == R_UnboundValue) {     /* ... SNIP ...*/     val = eval(PRCODE(e), PRENV(e));     /* ... SNIP ...*/     SET_PRSEEN(e, 0);     SET_PRVALUE(e, val);     ENSURE_NAMEDMAX

Re: [Rd] strange increase in the reference number

2019-07-13 Thread brodie gaslam via R-devel
If you would like more details I wrote about this recently: https://www.brodieg.com/2019/02/18/an-unofficial-reference-for-internal-inspect/ Basically as soon as you hit a closure R assumes that theargument might still have a surviving reference to iteven after the closure evaluation ends because

[Rd] Mitigating Stalls Caused by Call Deparse on Error

2019-07-13 Thread brodie gaslam via R-devel
When large calls cause errors R may stall for extended periods.  This is particularly likely to happen with `do.call`, as in this example with a 24 second stall:     x <- runif(1e7)     system.time(do.call(paste0, list(abs, x)))  # intentional error     ## Error in (function (..., collapse = NULL

[Rd] Documentation tweak for ?traceback

2019-07-10 Thread brodie gaslam via R-devel
The addition of `.traceback` in r70207 adds one more function to the call stack when invoking `traceback()`.  This changes the output of one of the examples to include the error handler call: > options(error = function() traceback(2)) > foo(2) [1] 1 Error in bar(2) : object 'a.variable.which.do

Re: [Rd] Use of C++ in Packages

2019-03-30 Thread Brodie Gaslam via R-devel
It's great to see the community mobilize to try to resolve this issue. Obviously C++ has become a big part of R extensions, so it would be nice to have clear guidelines and tools to be able to use C++ safely with the R API. Unfortunately doing this will probably require a fair bit of work. If

[Rd] Possible Update to R-internals Manual

2019-02-26 Thread brodie gaslam via R-devel
According the R-ints the only current uses of the `truelength` meta datum is for environment hash tables.  Jim Hester just made me aware that R3.4.0 introduces a new use case: growable vectors. I attach a patch to the R-ints manual that reflects this change.  The wording is obviously just a sug

[Rd] Possible setClassUnion Unloading Issue

2019-01-24 Thread Brodie Gaslam via R-devel
I'm encountering a problem caused by class unions from unloaded packages that are referenced by the still-loaded subclasses. In essence, when the class union is loaded initially, it registers itself as a super class of the component classes in the S4 cache. When the package the class union lives

Re: [Rd] setClass accepts slot-mismatch between slots and prototype arguments

2019-01-10 Thread brodie gaslam via R-devel
Indeed that was on oversight on my part.  It is surprising that things like this work: > setClass('test', slots=c(a='ANY'), prototype=list(a=NULL, b='hello')) > new('test')@b [1] "hello" > slotNames(new('test')) [1] "a" I'm planning a release of diffobj right now so I will fix this, but I agree

[Rd] grDevices::convertColor and colorRamp(space='Lab') Performance Improvements

2018-10-02 Thread Brodie Gaslam via R-devel
`grDevices::convertColor` performance can be improved by 30-300x with small changes to the code. `colorRamp(space='Lab')` uses `convertColor` so it too benefits from substantial performance gains. `convertColor` vectorizes explicitly over the rows of the input color matrix using `apply`. The

Re: [Rd] Fwd: Bug report: cbind with numeric and raw gives incorrect result

2018-09-25 Thread brodie gaslam via R-devel
For what it's worth the following patch fixes that particular problem on my system.  I have not checked very carefully to make sure this does not cause other problems, but at a high level it seems to make sense.  In this particular part of the code I believe `mode` is taken to be the highest

[Rd] Possible bug with chromatic adaptation in grDevices::convertColor

2018-09-13 Thread brodie gaslam via R-devel
It appears that the chromatic adaptation feature of `grDevices::convertColor`is broken, and likely has been for many years.  While a little surprising, it is an obscure enough feature that there is some possibility this is actually broken, as opposed to user error on my part.  If it turns out to

Re: [Rd] Possible `substr` bug in UTF-8 Corner Case

2018-03-29 Thread brodie gaslam via R-devel
hlighting this in the release notes. Best, Brodie. On Thursday, March 29, 2018, 9:11:15 AM EDT, Tomas Kalibera wrote: Thanks, fixed in R-devel (by checking validity of UTF-8 strings for substr/substring). Tomas On 03/29/2018 03:53 AM, brodie gaslam via R-devel wrote: > I think the

[Rd] Possible `substr` bug in UTF-8 Corner Case

2018-03-28 Thread brodie gaslam via R-devel
I think there is a memory bug in `substr` that is triggered by a UTF-8 corner case: an incomplete UTF-8 byte sequence at the end of a string.  With a valgrind level 2 instrumented build of R-devel I get: > string <- "abc\xEE"    # \xEE indicates the start of a 3 byte UTF-8 sequence > Encoding(st

[Rd] Illegal Logical Values

2017-10-20 Thread brodie gaslam via R-devel
I'm wondering if WRE Section 5.2 should be a little more explicit about misuse of integer values other than NA, 0, and 1 in LGLSXPs.  I'm thinking of this passage: > Logical values are sent as 0 (FALSE), 1 (TRUE) or INT_MIN = -2147483648 (NA, > but only if NAOK is true), and the compiled code s

[Rd] `c` with lists with "bytes" names encoding

2017-08-04 Thread brodie gaslam via R-devel
I'm not entirely sure this even qualifies as a bug given how unusual a case it is: > x <- list('a') > name.x <- '\x81' > Encoding(name.x) <- 'bytes' > names(x) <- name.x > x $`\\x81`[1] "a"> c(x)Error: translating strings with "bytes" encoding is not allowed > unlist(x) Error in unlist(x) :   tr

[Rd] `match.call` and dots substitution

2017-04-30 Thread brodie gaslam via R-devel
I'm noticing some interesting behavior in `match.call` in some corner-ish cases that arise when you try to use `match.call` to match a "grandparent" function and there are dots involved: fun0 <- function(a, ...) fun1(...) fun1 <- function(b, ...) fun2() fun2 <- function() m

Re: [Rd] Changes in error reporting in r-devel

2016-11-27 Thread brodie gaslam via R-devel
rk Eddelbuettel To: Duncan Murdoch Cc: brodie gaslam ; "r-devel@r-project.org" Sent: Sunday, November 27, 2016 2:44 PM Subject: Re: [Rd] Changes in error reporting in r-devel On 27 November 2016 at 13:20, Duncan Murdoch wrote: | On 27/11/2016 11:34 AM, brodie gaslam via R-devel wrote:

[Rd] Changes in error reporting in r-devel

2016-11-27 Thread brodie gaslam via R-devel
Minor issue, but the following changed as of R3.3.2 from: > a <- function() b() > a() Error in a() : could not find function "b" To (at least in R Under development (unstable) (2016-11-20 r71670)): Error in b() : could not find function "b" Notice the "Error in **b**() :" part.

[Rd] Frames in compiled functions

2016-11-11 Thread brodie gaslam via R-devel
I noticed some problems that cropped in the latest versions of R-devel (2016-11-08 r71639 in my case) for one of my packages. I _think_ I have narrowed it down to the changes to what gets byte-compiled by default. The following example run illustrates the problem I'm having: compiler::enabl

[Rd] A package that traces base functions

2016-09-29 Thread brodie gaslam via R-devel
I'm working on a package that implements a REPL.  A typical interaction with the package might look like: > launch_REPL()REPL> 1 + 1[1] 2REPL> QDo you wish to save results? [y/n]REPL> > ygoodbye ...> This is very similar to what happens when in `browser()`: the REPL evaluates arbitrary R user ex

[Rd] match.call enhancements in 3.2.2

2015-10-30 Thread brodie gaslam via R-devel
I was thrilled to see this in the change log: > match.call() gains an envir argument for specifying the environment from > which to retrieve the ... in the call, if any; this environment was wrong (or > at least undesirable) when the definition argument was a function. This was an issue I ran int

[Rd] Inconsistent Parse Behavior

2014-12-25 Thread brodie gaslam via R-devel
Under some specific conditions, `parse` seems to produce inconsistent and potentially incorrect results the first time it is run in a fresh clean R session.  Consider this code where we parse the same text twice in a row, and get one value in the parse data that is mismatched: ```Type 'demo()' f