DIP 1043---Shortened Method Syntax---Accepted

ryuukk_ ryuukk.dev at gmail.com
Sun Sep 25 13:00:08 UTC 2022


On Thursday, 22 September 2022 at 01:28:11 UTC, Doigt wrote:
> On Wednesday, 21 September 2022 at 10:39:27 UTC, Mike Parker 
> wrote:
>>>For example:
>>>
>>>     T front() => from;
>>>
>>>becomes:
>>>
>>>     T front => from;
>>
>> As DIP author, Max decided against this. He said it's not a 
>> bad idea, but it's then "inconsistent with other the other 
>> syntaxes". If there is a demand for this, it would be easy to 
>> add later, but he felt it's better to keep things simple for 
>> now by going with the current implementation as is.
>
> It's one of those things that aren't necessary, but bring some 
> small "quality of life" kind of change to the code we write. At 
> least in my opinion, I quite like it, the same way I like how I 
> can call a parameter-less function without parentheses.

It actually makes code very hard to read

Is it a field? is it a function, does it have arguments, or maybe 
it is just a static function, maybe it is a property, oh shoot i 
have to waste time trying to figure out what it is

It is same story with imprts, so now i exclusivly use named 
import ``import xxx = my.package.here`` 
``xx.my_global_function();``

This way when i read code, i know exactly what is doing what and 
from what module

This shortened method syntax is the same, it is a method, not a 
field, therefore it should require ``()``, i personally never 
omit it from the way i write function in my code, calling a 
function this way: ``this_is_a_function`` is imo very dangerous, 
i wish it was gone from the language


More information about the Digitalmars-d-announce mailing list