RFE: Class implements / extends in front of constructor params

Hi. I suggest to add an alternative place to declare the implemented interfaces and extended classes.
Why?

Because a lot of classes have a long list of properties, which pushes the more important information too below:

class Foo (
val name: String,
val surname: String,

val phone: String?) : Bar, Baz { … }

This has several negatives:

  1. Hardly readable - need to skim to find the line with implements /extends
  2. The default formatter in IDEA puts the information at the same line as last property, making it even less readable
  3. Not too useful when searching for the interface name by text - the line that comes out does not contain the implementing class (or sub) name

Someone might object with the logic that we are kind of writing the constructor that returns the type of the interface, but that’s not true… it’s returning the new class of course.

Simply put: This syntax would be way more readable, searchable and even more concise:

class Foo : Bar, Baz (
val name: String,
val surname: String,

val phone: String?
) { … }

It’s a bit late for such change, but perhaps both could be accepted? Or it could be an optional feature? I think it’s worth the negatives.
Also, I am aware that I can specify constructor explicitly, but that’s on the other hand more verbose for shorter classes (typically, data classes).

Thanks for considering.

1 Like

Also, IMHO, it would be more readable to have the extends and implements keywords.

I am not sure why it replaced it with : anyway. Maybe to make the syntax shorter, but then why the ternary operator would be replaced with if/else? …

I agree on your points, though there’s at least a catch, what happens if your super classes take parameters? Do you pass them before even declaring them?

class Foo: Baz(name[0] + "q") (
   ....
   val name: String,
   ....
)