SE-0289 (review #2): Result Builders

The issue I have with @resultBuilder is that it's unspecific—in a way every constructor or collection literal can be described as building a result.

To me, the most significant feature that is introduced by SE-0289 is not that it allows to write builders that produce results—that was possible before. It's the way how components of builder results are captured—by collecting values that would be ignored under normal semantics.

My preferred name for the attribute would therefore be @valueCollector. It describes concisely what is provided by the feature additionally to normal code execution (collection of unused values). The actual building is done in specific implementations (HTMLBuilder, TupleBuilder, etc). For those types the "Builder" suffix works very well, but I think for the feature that enables these kinds of builders the name @valueCollector works better as a disambiguation from other kinds of builders.

12 Likes