Extension Constructors

It’s not practical because: on author side, you trade a little convenience (less typing) with worse flexibility (you’re forced to pass a big chunk of code into this(...) call before any data validation); on user side, it’s just a style issue.

Named constructor looks like List.of. It’s a normal function, so you can do whatever you want, and it could reflect the intent just by its name (like, to differentiate List.of(10) and List(10)). This is covered by the upcoming static extension feature, so I noted it here.

Personally, I don’t feel like constructor, as a concept, should appear in places other than within the class itself. Few language did that either I suppose.

1 Like