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 g

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, 202

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 t

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 no