Re: RFR: 8197594 - String and character repeat

2018-02-26 Thread Stuart Marks
On 2/18/18 1:37 AM, James Laskey wrote: Didn’t I hear someone mentioning “\U1D11A” at some point? On 2/19/18 7:55 AM, Martin Buchholz wrote: Oops, I already got it wrong - it's already at 6 hex digits because there are 17 planes, not 16.  MAX_CODE_POINT is U+10. Yes, we need a variable

Re: RFR: 8197594 - String and character repeat

2018-02-26 Thread Stuart Marks
To close the loop on this, I've reopened JDK-4993841, which requests adding an API Character.toString(int) which converts an int codepoint value to a String. (This seems like the obvious API, in parallel with Character.toString(char), but of course alternatives could be considered.) s'marks

Re: RFR: 8197594 - String and character repeat

2018-02-19 Thread Martin Buchholz
. On Sun, Feb 18, 2018 at 11:19 AM, Martin Buchholz wrote: > > - how many digits to consume after the escape? How much do we trust > Unicode to never ever grow beyond 5 hex digits? > Oops, I already got it wrong - it's already at 6 hex digits because there are 17

Re: RFR: 8197594 - String and character repeat

2018-02-18 Thread Xueming Shen
On 2/18/18, 11:19 AM, Martin Buchholz wrote: On Sun, Feb 18, 2018 at 1:37 AM, James Laskey wrote: Didn’t I hear someone mentioning “\U1D11A” at some point? Unicode codepoint escapes are still Not a Thing, apparently. Yes, it's a language feature, but an easy one to

Re: RFR: 8197594 - String and character repeat

2018-02-18 Thread Martin Buchholz
On Sun, Feb 18, 2018 at 1:37 AM, James Laskey wrote: > Didn’t I hear someone mentioning “\U1D11A” at some point? > Unicode codepoint escapes are still Not a Thing, apparently. Yes, it's a language feature, but an easy one to implement. Except for the usual bikeshedding

Re: RFR: 8197594 - String and character repeat

2018-02-18 Thread Ulf Zibis
Am 18.02.2018 um 06:10 schrieb Stuart Marks: Fair enough. I'll be less unhappy if there is a way to convert from a code point to a String, as requested by JDK-4993841. This will reduce new String(Character.toChars(codepoint)).repeat(count) to

Re: RFR: 8197594 - String and character repeat

2018-02-18 Thread James Laskey
Didn’t I hear someone mentioning “\U1D11A” at some point? Sent from my iPhone > On Feb 18, 2018, at 1:10 AM, Stuart Marks wrote: > > Fair enough. I'll be less unhappy if there is a way to convert from a code > point to a String, as requested by JDK-4993841. This will

Re: RFR: 8197594 - String and character repeat

2018-02-17 Thread Stuart Marks
Fair enough. I'll be less unhappy if there is a way to convert from a code point to a String, as requested by JDK-4993841. This will reduce new String(Character.toChars(codepoint)).repeat(count) to Character.toString(codepoint).repeat(count) But this is still fairly roundabout. Since

Re: RFR: 8197594 - String and character repeat

2018-02-17 Thread Brian Goetz
> On Feb 17, 2018, at 9:40 AM, Martin Buchholz wrote: > > Let me join the chorus of agreement with Brian here. > > The most popular use case will forever be ASCII line of non-letter symbols. We may also wish to have a repeating version on StringBuilder, though:

Re: RFR: 8197594 - String and character repeat

2018-02-17 Thread Martin Buchholz
Let me join the chorus of agreement with Brian here. The most popular use case will forever be ASCII line of non-letter symbols. Another way to think about codepoints is as conversion between UTF-32 and UTF-16, or as general support for text in UTF-32 format, which is not supported well within

Re: RFR: 8197594 - String and character repeat

2018-02-17 Thread Remi Forax
- Mail original - > De: "Brian Goetz" <brian.go...@oracle.com> > À: "Xueming Shen" <xueming.s...@oracle.com> > Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net> > Envoyé: Samedi 17 Février 2018 03:30:10 > Objet: Re: R

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Brian Goetz
I really can’t see the value of more than one method. If we need other forms they should be for constructing strings not repeating strings. Sent from my MacBook Wheel > On Feb 16, 2018, at 6:12 PM, Xueming Shen wrote: > >> On 2/16/18, 5:13 PM, Stuart Marks wrote: >>

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Xueming Shen
On 2/16/18, 5:13 PM, Stuart Marks wrote: Let me put in an argument for handling code points: 3. public static String repeat(final int codepoint, final int count) Most of the String and Character API handles code points on an equal footing with chars. I think this is important, as over time

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Brian Goetz
Disagree. On #3, most of the time the char being repeated is already a literal. So just make it a string. On #2, better to aim for string.ofCodePoint(int) and compose w repeat. Down to one method again :) Sent from my MacBook Wheel > On Feb 16, 2018, at 5:13 PM, Stuart Marks

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Stuart Marks
Let me put in an argument for handling code points: 3. public static String repeat(final int codepoint, final int count) Most of the String and Character API handles code points on an equal footing with chars. I think this is important, as over time Unicode is continuing to add

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Jim Laskey
We’re going with the one instance method (Louis clinched it.) with recommended enhancements and not touching CharSequence. Working it up now. — Jim > On Feb 16, 2018, at 7:46 AM, Alan Bateman wrote: > > On 15/02/2018 17:20, Jim Laskey wrote: >> This is a pre-CSR code

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Alan Bateman
On 15/02/2018 21:59, Joseph D. Darcy wrote: : My general recommendation if the code review and CSR review are to be serialized is to estimate which one is more likely to generate feedback that might modify the proposal and run though that process first. Since there has already been feedback

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Alan Bateman
On 15/02/2018 17:20, Jim Laskey wrote: This is a pre-CSR code review [1] for String repeat methods (Enhancement). The proposal is to introduce four new methods; 1. public String repeat(final int count) 2. public static String repeat(final char ch, final int count) 3. public static String

Re: RFR: 8197594 - String and character repeat

2018-02-16 Thread Stephen Colebourne
On 15 February 2018 at 20:52, Louis Wasserman wrote: > Based on this data, I'd recommend providing one and only one method of this > type: String.repeat(int). Only adding the one instance method seems like the best plan in this case. Stephen

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Joseph D. Darcy
On 2/15/2018 12:38 PM, Roger Riggs wrote: Hi Jim, Its cleaner to do the API (CSR) review before and without the implementation. It helps keep the issues separate. Don't make statements about count == Integer.MAX_VALUE / 2. There is no point, unless it should throw IAE. My general

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Brian Goetz
This matches my intuition too. Sent from my MacBook Wheel > On Feb 15, 2018, at 12:52 PM, Louis Wasserman wrote: > > I don't think there's a case for demand to merit having a > repeat(CharSequence, int) at all. > > I did an analysis of usages of Guava's Strings.repeat

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread James Laskey
Good to have the data. Thank you Louis. Sent from my iPhone > On Feb 15, 2018, at 4:52 PM, Louis Wasserman wrote: > > I don't think there's a case for demand to merit having a > repeat(CharSequence, int) at all. > > I did an analysis of usages of Guava's

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Louis Wasserman
I don't think there's a case for demand to merit having a repeat(CharSequence, int) at all. I did an analysis of usages of Guava's Strings.repeat on Google's codebase. Users might be rolling their own implementations, too, but this should be a very good proxy for demand.

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Jim Laskey
n returning CharSequence, a String is a CharSequence and > can be used anywhere > a CharSequence can. > > $.02, Roger > >> >> — Jim >> >>> Rémi >>> >>> - Mail original - >>>> De: "Jim Laskey" <james.las...@orac

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Roger Riggs
;Jim Laskey" <james.las...@oracle.com> À: "Brian Goetz" <brian.go...@oracle.com> Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net> Envoyé: Jeudi 15 Février 2018 18:34:19 Objet: Re: RFR: 8197594 - String and character repeat Very reasonable approach. On Feb 15,

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread forax
uld play safe here and only add repeat to String. > > — Jim Rémi > >> >> Rémi >> >> - Mail original - >>> De: "Jim Laskey" <james.las...@oracle.com> >>> À: "Brian Goetz" <brian.go...@oracle.com> >>&

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Jim Laskey
s.las...@oracle.com>, "core-libs-dev" >> <core-libs-dev@openjdk.java.net> >> Envoyé: Jeudi 15 Février 2018 20:36:44 >> Objet: Re: RFR: 8197594 - String and character repeat > >> Hello! >> >> The link with the webrev returned 404, but I could find it at

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Remi Forax
- Mail original - > De: "Ivan Gerasimov" <ivan.gerasi...@oracle.com> > À: "Jim Laskey" <james.las...@oracle.com>, "core-libs-dev" > <core-libs-dev@openjdk.java.net> > Envoyé: Jeudi 15 Février 2018 20:36:44 > Objet: Re: RFR

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Jim Laskey
its use (methods expecting strings.) — Jim > > Rémi > > - Mail original - >> De: "Jim Laskey" <james.las...@oracle.com> >> À: "Brian Goetz" <brian.go...@oracle.com> >> Cc: "core-libs-dev" <core-libs-dev@openj

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Remi Forax
-libs-dev@openjdk.java.net> > Envoyé: Jeudi 15 Février 2018 18:34:19 > Objet: Re: RFR: 8197594 - String and character repeat > Very reasonable approach. > > >> On Feb 15, 2018, at 1:31 PM, Brian Goetz <brian.go...@oracle.com> wrote: >> >> I suggest m

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Jim Laskey
> On Feb 15, 2018, at 3:36 PM, Ivan Gerasimov wrote: > > Hello! > > The link with the webrev returned 404, but I could find it at this location: > http://cr.openjdk.java.net/~jlaskey/8197594/webrev-00/ > > A few minor comments: > > 1) > > This check: > > 2992

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Ivan Gerasimov
Hello! The link with the webrev returned 404, but I could find it at this location: http://cr.openjdk.java.net/~jlaskey/8197594/webrev-00/ A few minor comments: 1) This check: 2992 final long limit = (long)count * 2L; 2993 if ((long)Integer.MAX_VALUE < limit) { can

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Jim Laskey
Very reasonable approach. > On Feb 15, 2018, at 1:31 PM, Brian Goetz wrote: > > I suggest merging 1 and 4 by making it an instance method on CS with a > default in CS and an override on string and string builder? > > Sent from my MacBook Wheel > >> On Feb 15, 2018,

Re: RFR: 8197594 - String and character repeat

2018-02-15 Thread Brian Goetz
I suggest merging 1 and 4 by making it an instance method on CS with a default in CS and an override on string and string builder? Sent from my MacBook Wheel > On Feb 15, 2018, at 9:20 AM, Jim Laskey wrote: > > This is a pre-CSR code review [1] for String repeat