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

Timon Gehr timon.gehr at gmx.ch
Fri Jul 1 01:10:28 UTC 2022


On 7/1/22 02:06, welkam wrote:
> On Tuesday, 28 June 2022 at 16:32:46 UTC, Timon Gehr wrote:
>>> Go language is the way it is for valid reasons. Don't dismiss them 
>>> easily.
>>
>> Why not? I dislike Go for valid reasons.
> 
> I dont like Go as a language as well but I can still recognize that 
> simplicity and uniformity is a valuable thing.

Go is neither simple nor uniform. The DIP is making D a bit simpler and 
more uniform.

> Now its crystal clear 
> that I was unable to effectively communicate what I was thinking. The 
> problem is that I dont know how else should I did it.
> 
> Google has a problem that they constantly are hiring new programmers and 
> those programmers write code in their own way. Code bases written this 
> way are not optimal. Go being the way it is makes its so that it easier 
> to teach the language and its easier to onboard new programmer onto the 
> project.

I don't buy it, and neither should you or anyone else.

https://programming.guide/go/go-gotcha.html
https://fasterthanli.me/articles/lies-we-tell-ourselves-to-keep-using-golang

> I'm not going to list the negative trade offs of Go`s design 
> decisions as I believe its obvious for people in this forum. On the 
> other hand the benefits of Go or C designs seem to be valued at 0.
> 
> Discussions here revolved around question "do you want these benefits or 
> not?" while it should have been "do you think the benefits are worth the 
> tradeoffs?". Instead of talking about the best case scenario of one line 
> functions in classes more time should have given to other possible uses 
> and its effects on readability.
> 
> ```d
> auto bar() => iota(1, 100)
>                      .map!(x => x + 1)
>                      .filter!(x => x > 4)
>                      .foo();
> ```
> 
> ```d
> auto bar = iota(1, 100)
>                  .map!(x => x + 1)
>                  .filter!(x => x > 4)
>                  .foo();
> ```
> Code like this is going to be written and I didnt saw discussions about 
> it or any other potential reduction in scanability of a code as a result 
> of the proposed changes.
> ...

I guess that's mostly because everyone else who has been inclined to 
join the discussion understands that this is very readable code. Also, I 
don't think you even understand what this DIP is proposing. The second 
snippet is already valid D code with or without this DIP.

> Before starting to write in this thread I looked at how setters and 
> getters are taught in C# as that language has implemented shorter 
> syntax. 3 out of 3 videos did not feature this shorter syntax for one 
> line functions. Any guesses as to why?

They did not bother to update the videos. The shorthand syntax is a bit 
less general, and chances are people will just pick it up from 
encountering it in the wild. It's very obvious what it means.

There is just not much to see here. There's much more productive things 
to argue about.


More information about the Digitalmars-d mailing list