RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char
Ulf.Zibis at CoSoCo.de
Thu Dec 8 09:01:29 UTC 2016
Am 08.12.2016 um 09:28 schrieb Peter Levart:
> On 12/07/2016 11:28 PM, Roger Riggs wrote:
>> I agree with Claes' comment suggesting that IAE for negative lengths is a pain
>> and defining it to append 0 would be natural in many use cases.
> OTOH, inserting a simple Math.max(n, 0) instead of n where n could get negative would achieve the
> same without complicating the expression too much. Java standard APIs have a tradition of being
> explicit rather than having implicit hidden logic which surely shortens many usecases, but makes
> them harder to read and understand for casual readers not intimately familiar with such API. The
> logic to treat negative lengths as 0 is implicit and not universally correct.
If we would treat negative values as 0, we loose a chance, where programmers could become aware
about possible errors in the logic of their program.
More information about the core-libs-dev