On Tuesday, May 16, 2017 17:22:12 Timon Gehr via Digitalmars-d wrote: > On 15.05.2017 03:18, Jonathan M Davis via Digitalmars-d wrote: > > So, while I do like the idea of getting the word body back as an > > identifier, what really appeals to me here is getting rid of the need > > for it with contracts. > > auto foo()in{ > assert(true); > }out{ > assert(true); > }{ > return 3; > } > > Are you really arguing for this? > I don't want to write code like this.
Well, I can't say that I like the formatting, but most definietly I am arguing for that. Right now, just because you add contracts, you suddenly have to add an extra keyword that is unnecessary when there are no contracts and which is redundant. You go from having something like auto foo(T param) { ... } to something like auto foo(T param) in { assert(...); } out(result) { assert(...); } body { ... } or auto foo(T param) in { assert(...); } out(result) { assert(...); } body { ... } or however you want to format it. But the last set of braces is always the function body just like it is when there are no contracts. And having to have body (or function whatever other keyword we might put there) just makes contracts that much more verbose - as well as being inconsistent with how functions bodies are declared when there are no contracts. Honestly, as nice as it would be to get the body keyword back as an identifier, I care _way_ more about not having a redundant keyword for the function body. I'd be all for removing it from contracts even if we never got it back as an identifier. I've always found needing to add body to be very annoying, and I frequently forget it, because it's not there normally. It's just making contracts longer without adding extra information, and contracts are _way_ too verbose even without the extra keyword there, let alone with it. IMHO, if we remove body as a keyword but replace it with something else in contracts, we've lost out on a big opportunity for some language cleanup. - Jonathan M Davis