DIP 1009--Improve Contract Usability--Preliminary Review Round 1
MysticZach via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jun 22 21:08:39 PDT 2017
On Friday, 23 June 2017 at 00:17:23 UTC, Steven Schveighoffer
wrote:
> int foo()
> out(result)
> {
> }
>
> what does this mean? Does it mean assert(result) on the out
> contract, or this is the old form of out?
>
> If we didn't have contract syntax already, and many existing
> code bases that use it, I'd say this would be the way to go.
The current grammar is:
OutStatement:
out ( Identifier ) { Statement }
out { Statement }
So one way out is simply to demand that there be more than just
an identifier when checking in the new way. So you'd have to
require more tokens, e.g.`out(result !is null)` instead of just
`out(result)` in order for the parser to easily distinguish
between the two. It's a little messy. On the other hand,
requiring two sets of parens is clean, but ugly. So it's a choice
between ugly and messy, unless someone comes up with something
more elegant.
More information about the Digitalmars-d
mailing list