# For .... if ... syntax?

**URL:** <https://discourse.julialang.org/t/for-if-syntax/64559>\
**Category:** Internals & Design\
**Tags:** loops, control-flow\
**Created:** [July 13, 2021, 12:03pm UTC](https://discourse.julialang.org/t/for-if-syntax/64559 "2021-07-13T12:03:36Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 13, 2021, 1:18pm UTC](https://discourse.julialang.org/t/for-if-syntax/64559/6 "2021-07-13T13:18:29Z")

</div>

> [@dstarerstor](#):
>
> doesn’t do anything that we can’t achieve with using `filter` or boolean indexing.

Neither is not a good comparison. Using the `[... for ... in ... if ...]` syntax avoids creating temporaries for the unfiltered interim results, boolean indexing OTOH would require them. `filter` operates on existing iterators, the comprehension syntax creates iterators and collects them; a pretty common use case.

The point is not to avoid any kind of parallel solution — that neither desirable nor practical — but to have a small number of orthogonal building blocks that combine well. For this particular purpose, control flow already works very well.

On a somewhat related note, I admire how clean Julia is from a control flow perspective. Basic (non-coroutine) control flow has combounding (`begin`, `( ; )`), two kinds of loops (`for`, `while`), branching and short-circuiting boolean ops, and the standard exception handling constructs. And that’s it! We can build the rest easily from these components. (Technically `for` is redundant once we have `while`, but it meshes so well with iteration that it is worth it).

---

_[View the full topic](https://discourse.julialang.org/t/for-if-syntax/64559)._
