Raw String Literals indentation management
Guy Steele
guy.steele at oracle.com
Thu Jun 7 17:48:51 UTC 2018
> On Jun 7, 2018, at 1:42 PM, Jim Laskey <james.laskey at oracle.com> wrote:
>
>> On Jun 7, 2018, at 1:39 PM, Guy Steele <guy.steele at oracle.com <mailto:guy.steele at oracle.com>> wrote:
>>
>>> On Jun 7, 2018, at 9:11 AM, Jim Laskey <james.laskey at oracle.com <mailto:james.laskey at oracle.com>> wrote:
>> . . .
>> The name “lines” is similarly uninformative, and the LinesOptions business seems kind of clunky: useful if we expect to be “computing lines options”, but if not, I would rather see
>>
>> System.out.println(`
>> abc
>> def
>> ghi
>> `.removeOneLeadingBlankLine().removeOneTrailingBlankLine().count());
>>
>> and other available methods are
>>
>> removeAllLeadingBlankLines()
>> removeAllTrailingBlankLines()
>> removeAllSurroundingBlankLines()
>> removeAllBlankLines()
>>
>> which I think would cover 99.9% of uses.
>
> Any shorter naming options?
Sure: remove the word “All” from those last four names. Too bad we don;t have a single word for “Blank Line”.
> Assuming you are returning Strings, this would be costly (string copying), but reasonable.
I was relying on your earlier assertion that in most cases there transformations get done at compile time . . .
>
> If you are returning Stream<String>, first and last combinators really suck with streams. That is, you have to make full passes with each call.
. . . but, d’oh! I forgot that streams are involved here. “Never mind.” So you really would need individual methods, and that’s pushing the number of methods pretty high.
>
> Internally, I have it implemented as .lines(int maxLeadingBlanksRemoved, int maxTrailingBlanksRemoved)
>
> System.out.println(`
> abc
> def
> ghi
> `.lines(1,1)).count();
>
> This keeps everything single pass.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20180607/d5b597ca/attachment-0001.html>
More information about the amber-spec-experts
mailing list