DIP 1009--Improve Contract Usability--Preliminary Review Round 1
Moritz Maxeiner via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 21 05:05:55 PDT 2017
On Wednesday, 21 June 2017 at 09:53:40 UTC, meppl wrote:
> On Wednesday, 21 June 2017 at 09:27:20 UTC, MysticZach wrote:
>> On Wednesday, 21 June 2017 at 08:15:34 UTC, MysticZach wrote:
>>> On Wednesday, 21 June 2017 at 04:16:22 UTC, Moritz Maxeiner
>>> wrote:
>>>> int myFunc(Args...)(Args args)
>>>> if (Args.length > 2)
>>>> in (args[0] != 0)
>>>> in (args[1] > 1)
>>>> out (result => result > 0) { ... }
>
> avoiding the "anonymous scope"-extra wouldnt hurt much?
>
> int myFunc(Args...)(Args args)
> if (Args.length > 2)
> in (args[0] != 0)
> in (args[1] > 1)
> out (result => result > 0)
> do { ... }
Adding `if (...)` should not be different from adding `in (...)`
or `out (...)` in terms of syntax rules: it's inconsistent. If
you want to have that `do` there, I would argue that it should
also become required if only an `if (...)` is present, so
---
int myFunc(Args...)(Args args)
if (Args.length > 2)
{ ... }
---
should then become illegal and must be rewritten as
---
int myFunc(Args...)(Args args)
if (Args.length > 2)
do { ... }
---
I doubt that's going to happen, though (too much code breakage),
and I also don't like it. Simply drop the `do`.
More information about the Digitalmars-d
mailing list