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

2021-06-22 Thread Tomas Kalibera
On 6/21/21 9:25 PM, Bill Dunlap wrote: NULL cannot be in an integer or numeric vector so it would not be a good fit for substring's 'first' or 'last' argument (or substr's 'start' and 'stop'). Yes, that would only work if used as a scalar, such as in the default for 'last' where 100L is

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

2021-06-21 Thread Bill Dunlap
NULL cannot be in an integer or numeric vector so it would not be a good fit for substring's 'first' or 'last' argument (or substr's 'start' and 'stop'). Also, it is conceivable that string lengths may be 64 bit integers in the future, so why not use Inf as the default? Then the following would

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

2021-06-21 Thread Michael Chirico
Thanks all, great points well taken. Indeed it seems the default of 100 predates SVN tracking in 1997. I think a NULL default behaving as "end of string" regardless of encoding makes sense and avoids the overheads of a $ call and a much heavier nchar() calculation. Mike C On Mon, Jun 21,

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

2021-06-21 Thread Martin Maechler
> Tomas Kalibera > on Mon, 21 Jun 2021 10:08:37 +0200 writes: > On 6/21/21 9:35 AM, Martin Maechler wrote: >>> Michael Chirico >>> on Sun, 20 Jun 2021 15:20:26 -0700 writes: >> > Currently, substring defaults to last=100L, which >> > strongly suggests

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

2021-06-21 Thread Tomas Kalibera
On 6/21/21 9:35 AM, Martin Maechler wrote: Michael Chirico on Sun, 20 Jun 2021 15:20:26 -0700 writes: > 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.

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

2021-06-21 Thread Martin Maechler
> Michael Chirico > on Sun, 20 Jun 2021 15:20:26 -0700 writes: > 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

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$integer.max.  What happened below is a > bug

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