Jonathan M Davis:

Agreed. This would just add more stuff to the language that people would have to understand,

Now there are languages with such idea, like TypeScript and Scala, so I think programmers can grasp this simple idea quickly.


and it really doesn't add much benefit. It's just a slightly terser syntax -

It's a more dry syntax, it saves typing, reduces the noise, and makes the code less bug-prone because it's more DRY, you have to repeat similar things less times. So I think it's a good idea for D.

It also partially replaces my idea of giving a warning/error when you have arguments equal to field names, because it removes a source for a common bug (this code compiles with no errors nor warnings and shows a different but related bug):

struct Foo {
    int x;
    this(in int x_) {
        x = x;
    }
}
void main() {}

Bye,
bearophile

Reply via email to