[RSL] RSL update

Brian Goetz brian.goetz at oracle.com
Tue Jun 26 12:09:35 UTC 2018

> Here are two more arguments in favor of language-level stripping:
> 1. Strings inside annotations aren't left out. Whenever an annotation 
> attribute feels like something users may want to use an RSL for, the 
> best we can hope for (if we don't have automatic unindenting) is for 
> the specification of that attribute to say "consumers of this data 
> /really should/ call .align() on this" - quite unsatisfying, and we 
> can be sure most annotation specs won't bother.

This seems like a pretty corner^3 case to me; long strings in 
annotations are kind of questionable already, multi-line strings in an 
annotation seem even more so, and in those cases where you absolutely 
need to be divorced from the incidental indentation, you could just 
align it yourself correctly, at the cost of uglier indentation (or pull 
it out into a static var.)

> I am still slow to convince myself that language-based unindenting is 
> absolutely definitely better; however, I do feel like the cited 
> advantages for library-based unindenting are just a bit questionable:

Fair enough, but also -- putting something in the language must meet a 
higher burden than putting it in a library. If we get the library wrong, 
we can fix it; if there are more than one reasonable way to do 
something, we can provide alternate library points for the other cases 
(.alignDammit()); and users can always create their own libraries for 
string manipulation if the built-in ones are not right for their 
purposes.  But, if we put it in the language, this will be the Only Way 
Forever.  The bar there is high.

> Do we have stronger arguments in this column than these?

Here's one I worry about.  Will we get the right result with this?

String s = `
   - person:
      - name: /` + name + `/
      - age: 127`;

The second string starts left-justified, so we will strip nothing from 
it.  So with auto-align, I think we get this:

- person:
   - name: /bob/
- age: 127

which is not what we wanted (and YAML won't like this.)

(Yes, I know many will say "well, if you idiots just did string 
interpolation, this wouldn't be an issue", but if string literals and 
concatenation don't play nicely together, that would be pretty bad.)

By leaving it to the user, they are free to put the align where it belongs:

String s = (`
   - person:
      - name: /` + name + `/
      - age: 127`).align();

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20180626/8b8c666c/attachment.html>

More information about the amber-spec-experts mailing list