Discussion Thread: DIP 1043--Shortened Method Syntax--Final Review

Basile B. b2.temp at gmx.com
Wed Jun 15 11:45:14 UTC 2022


On Wednesday, 15 June 2022 at 09:35:37 UTC, bauss wrote:
> On Wednesday, 15 June 2022 at 09:21:12 UTC, Mike Parker wrote:
>> This is the discussion thread for the Final Review of DIP 
>> 1043, "Shortened Method Syntax":
>>
>> https://github.com/dlang/DIPs/blob/2c2f6c33f5761236266a96bd268c62a06323a5e8/DIPs/DIP1043.md
>>
>> The review period will end at 11:59 PM ET on June 29, or when 
>> I make a post declaring it complete. Discussion in this thread 
>> may continue beyond that point.
>>
>> Here in the discussion thread, you are free to discuss 
>> anything and everything related to the DIP. Express your 
>> support or opposition, debate alternatives, argue the merits, 
>> etc.
>>
>> However, if you have any specific feedback on how to improve 
>> the proposal itself, then please post it in the feedback 
>> thread. The feedback thread will be the source for the review 
>> summary I write at the end of this review round. I will post a 
>> link to that thread immediately following this post. Just be 
>> sure to read and understand the Reviewer Guidelines before 
>> posting there:
>>
>> https://github.com/dlang/DIPs/blob/master/docs/guidelines-reviewers.md
>>
>> And my blog post on the difference between the Discussion and 
>> Feedback threads:
>>
>> https://dlang.org/blog/2020/01/26/dip-reviews-discussion-vs-feedback/
>>
>> Please stay on topic here. I will delete posts that are 
>> completely off-topic.
>
> I'm still under the belief that it shouldn't just be 
> `AssignExpression`, because you should be able to use it to 
> call another function that has no return type.
>
> Ex.
>
> ```d
> void a(int x, int y) { ... }
>
> void b(int x) => a(x, 100);
> ```
>
> As the DIP uses C# as a prime example of it, because the above 
> will work in C#.
>
> It's very useful for things like this:
>
> ```d
> @property int x() => _x;
> @property void x(int value) => _x = value;
> ```
>
> C# equivalent:
>
> ```d
> int X { get => _x;  set => _x = value; }
> ```
>
> I might not understand something from the DIP, but I don't 
> think it's clear whether that is supported or not and 
> `AssignExpression` tells me that it's not, but maybe I don't 
> understand what `AssignExpression` exactly entails.

AssignExp does not mean that there's an assignment, it just parse 
everything from that but can returns a simple primary, e.g 
IntegerExp.

Otherwise the concern about void is valid but I think that this 
can be solved easily during the semantic passes: if we're in a 
func and if we're in a shortened func then if this func is void 
then inserts a void cast to the expression. No technical issue 
there, as long as there's a flag that makes shortened funcs 
recognizable after lowering.

```d
// void f() => 0;
void f() {return cast(void)0;}
```


More information about the Digitalmars-d mailing list