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

Kagamin spam at here.lot
Wed Feb 9 13:40:36 UTC 2022


In my experience with C# this features is underwhelming. I 
searched our codebase and couldn't find many shortened methods, 
autoproperties are used much more often. Methods simply tend to 
be at leas a couple of lines long and can't be shortened easily.

Some examples:
```
private bool isCanceled() => _state == RequestState.canceled;
private bool isCanceled() { return _state == 
RequestState.canceled; }
```
61 and 69 characters respectively, 12% saving.

A single valued method:
```
IClient create(string address)
{
	return new Client(
		new DefaultProducerEndpoint(address, _producerFactory.create(), 
0),
		new DefaultConsumerEndpoint(address, _consumerFactory.create()),
		new DefaultBrokerEndpoint(address, _brokerFactory.create()),
		null);
}
```
Ermm... should it be shortened?


More information about the Digitalmars-d mailing list