On Wednesday, 21 June 2017 at 12:05:55 UTC, Moritz Maxeiner wrote:
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`.


yeah, i was probably not thinking too carefully about it. My idea was to keep the code readable, if the contracts are long. but as long as the "do" must appear behind a '}', everything is still fine, more or less.


        int myFunc1(Args...)(Args args)
        if (Args.length > 2)
        in
        {
                // much code
        }
        do
        {
                ...
        }


        int myFunc2(Args...)(Args args)
        if (Args.length > 2)
        in
        {
                // much code
        }
        out (result => result > 0)
        {
                ...
        }


both are readable, but one time we write `do` and the other time we dont. furthermore the second function body looks a little bit like belonging to "out". someone who is learning the D-language might get confused.

Reply via email to