On Wed, May 17, 2017 at 05:06:40PM +0000, MysticZach via Digitalmars-d wrote: [...] > 3. If `body` were optional, probably a lot of people wouldn't be using > it to begin with. I suspect that Jonathan and I are not alone in > thinking that it's not just useless, it's annoying. Thus, only code > that uses it would have this problem.
FWIW, I also find it annoying. Very annoying, in fact. The underlying gripe I have with it (apart from verbosity) is the asymmetry caused by the appearance of an extra(neous) keyword `body` in front of what is otherwise an undecorated {...} function body block, just because optional elements (in/out) were introduced. In other words, what irks me is that when there are no contracts, you have this: auto func(...) { /* code */ } But when there are contracts, not only do the contracts themselves appear (in {...} and/or out(...){...}), but an extraneous keyword `body` also appears. To put this in context, consider all the variations together: auto func(...) { /* code */ } auto func(...) in{...} body { /* code */ } auto func(...) out(...){...} body { /* code */ } auto func(...) in{...} out(...){...} body { /* code */ } Notice how the appearance of `body` in the 2nd to 4th lines sticks out like a sore thumb. Since in{...} and out(...){...} are optional elements, it would be more aesthetically pleasing if they did not also affect the syntax around them, e.g.: // Now they are truly optional, and the surrounding syntax // doesn't change by their presence/absence. auto func(...) { /* code */ } auto func(...) in{...} { /* code */ } auto func(...) out(...){...} { /* code */ } auto func(...) in{...} out(...){...} { /* code */ } Alternatively, the asymmetry would be eliminated if `body` was a *required* keyword before the function body, e.g.: auto func(...) body { /* code */ } auto func(...) in{...} body { /* code */ } auto func(...) out(...){...} body { /* code */ } auto func(...) in{...} out(...){...} body { /* code */ } But I doubt anyone here would agree to making `body` a required keyword when there are no contracts! T -- Unix is my IDE. -- Justin Whear