[RSL] RSL update

Brian Goetz brian.goetz at oracle.com
Tue Jun 26 19:29:16 UTC 2018


> The workaround exists, but first users will fall into the pit before they realize what went wrong. Is this reason enough that we should change `align` to a static method? That actually makes this problem more or less vanish.

It makes it impossible to forget to use parens, which is good, but I think it will be less pleasant to use, especially with other designed-for-chaining methods being added (indent(), etc.)  People like chaining because it specifies the operations in the order they actually happen, which is easier to read.  So I would be concerned that this cure has undesirable side effects.  

> That said, I wonder if users are better served by switching to `String.format` whenever possible, anyway. They should .align() the format string instead of the formatted result. It's more foolproof, and they still get the benefit of align() happening at (compile time? load time? whenever the new magic happens). Output will be consistent even if a piece of data unexpectedly contained a newline.  I'm roughly expecting to be giving users the advice to avoid mixing RSLs with concatenation altogether.

I think both bits of advice — use format, and avoid mixing — are likely to be good style advice regardless.  But even if we had interpolation, string literals and string concatenation are fundamental features that should work well together.  Having two such fundamental features that can’t be used together is pretty worrying to me.



More information about the amber-spec-experts mailing list