1. Hiding a semantic "if" inside a "for"-loop syntax is not good, in my book - in C++ I would have introduced a "returnIf"-macro to make the intention clear in that case... ;-)

2. I was also thinking along the same line, but more like:

if(it = goo(); a>6 && it>10) { return it }

How does the return know what to return in your example, btw... ?-)

3. Would the "it" variable in the ClosureList move from term to term, i.e. it would always reference the last term before the current one, or always refernce the first ?

Cheers,
mg

PS: The difference between
returnIf (goo(); a>6 && it>10)
and
returnIf (goo(), a>6 && it>10)
is of course miniscule, and maybe the second variety might actually be less confusing... (?)



On 30/07/2020 10:26, Jochen Theodorou wrote:
On 30.07.20 01:10, Daniel Sun wrote:
Hi mg,

      I like your idea, but it's hard for IDE to infer the type of `it` during we coding.

```
returnIf(a > 6 && it > 10) { goo() }
```


long time ago I made the suggestion of a ClosureList based on the
classic for: "(" expr (";" expr)+ ")". It  got shot down very much for
being so ugly, but using that, we would get this:

```
returnIf (goo(); a>6 && it>10)
```

of course going crazy we could move this further:

```
for (goo(); a>6 && it>10;) {return}
```

or


```
for (goo(); a>6 && it>10; return)
```

bye Jochen

Reply via email to