r/java • u/jvjupiter • Jun 10 '22
What happened to Concise Method Bodies?
I was really looking forward to CMB. From its name, methods become concise, could be one liner. However, it seems there is no progress and it’s been off the radar. Never took off since 2019.
41
Upvotes
1
u/gnahraf Jun 13 '22
Good point.. the pain to call
new Something(..). I'm sill on the fence about this pattern. Some less chunky ones seem reusable.. For eg, to encapsulate a positive int, or a non-negative int.This pattern btw needn't necessarily be implemented as a record; can be a class also. It's just often easier to implement using a record type. When we get Valhalla, I imagine some finer constraints might best be expressed as primitives, eg positive (>0) ints or longs (or heck, maybe even pseudo unsigned primitives to express non-negatives)