Discussion Thread: DIP 1043--Shortened Method Syntax--Community Review Round 1

Basile B. b2.temp at gmx.com
Sat Feb 5 10:09:16 UTC 2022


On Friday, 4 February 2022 at 18:21:44 UTC, Timon Gehr wrote:
> On 04.02.22 19:03, Basile B. wrote:
>> On Friday, 4 February 2022 at 17:18:54 UTC, Tejas wrote:
>>> So maybe the fact that `this(string y) => this(0, y);` 
>>> doesn't compile is a compiler bug? Constructors return `void` 
>>> after all, no?
>> 
>> No, aggregate ctors are not `void` but the return is generated 
>> [by the 
>> compiler](https://github.com/dlang/dmd/blob/51882e40fd17ed4b57a8ce3a355ea76b55d777c9/src/dmd/semantic3.d#L771-L780).
>> 
>> 
>
> That's an implementation/ABI detail. Plain "return" is allowed, 
> just as if the constructor returned `void`.
>
> https://github.com/dlang/dmd/blob/51882e40fd17ed4b57a8ce3a355ea76b55d777c9/src/dmd/statementsem.d#L2849-L2852
>
> Therefore, it makes sense to do this rewrite in constructors 
> too:
> https://github.com/dlang/dmd/blob/51882e40fd17ed4b57a8ce3a355ea76b55d777c9/src/dmd/statementsem.d#L2896-L2910

sure, but my point was to say that Tejas assumption about void 
returns was wrong.

Anyway, it is not reported in the feedback thread for now. The 
document should mention something about ctor calls since the 
compiler does special things that
prevent shorthand syntax to work.


More information about the Digitalmars-d mailing list