Feedback on Átila's Vision for D

Meta jared771 at gmail.com
Mon Oct 21 13:44:16 UTC 2019


On Monday, 21 October 2019 at 13:20:05 UTC, Exil wrote:
> On Monday, 21 October 2019 at 12:34:14 UTC, Meta wrote:
>> On Sunday, 20 October 2019 at 20:41:01 UTC, Exil wrote:
>>> Sure, one can argue that it's not a bug, auto-decoding isn't 
>>> a bug, in fact it was very much intentional. But I think we'd 
>>> all be better off without it. The way it is implemented can 
>>> lead to bugs quite easily. Since it picks whichever one based 
>>> on order.
>>
>> Show me a concrete example. Also, there is no "picking" of 
>> which interface method is implemented. Both are implemented by 
>> the same method.
>
> interface OneThing {
>     void foo(); // should do One thing
> }
>
> interface AnotherThing {
>     void foo(); // do another thing
> }
>
> class A : OneThing, AnotherThing {
>     override void foo() { }
> }
>
>
> void bar(OneThing o) {
>    o.foo(); // do something unrelated to AnotherThing
> }
>
> void tar(AnotherThing a) {
>    a.foo(); // do something unrelated to OneThing
> }
>
>
> void main() {
>     A a = new A;
>
>     bar(a);
>     tar(a);
> }
>
>
> Your assumption is that just because the functions are named 
> the same thing then they should do the exact same thing.

You're talking about the semantic appropriateness of A.foo doing 
the same thing whether A is accessed through a reference to a 
OneThing or an AnotherThing. I'm talking about whether it is a 
bug or not, i.e., the correctness of the behaviour of the 
implementation from a theoretical perspective.

Compiler's don't examine your code for conformance to a given set 
of semantics; that's up to humans. The best they can do is check 
that your program is well-formed.


More information about the Digitalmars-d mailing list