# Will my variable be modified in a \`do\` block? Very subtle to anticipate

**URL:** <https://discourse.julialang.org/t/will-my-variable-be-modified-in-a-do-block-very-subtle-to-anticipate/131124>\
**Category:** General Usage\
**Tags:** question, threads\
**Created:** [July 28, 2025, 6:25am UTC](https://discourse.julialang.org/t/will-my-variable-be-modified-in-a-do-block-very-subtle-to-anticipate/131124 "2025-07-28T06:25:02Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [July 28, 2025, 11:28am UTC](https://discourse.julialang.org/t/will-my-variable-be-modified-in-a-do-block-very-subtle-to-anticipate/131124/14 "2025-07-28T11:28:09Z")

</div>

> [@sgaure](#):
>
> put code in functions

Thanks, I take your point.

* * *

(Update)

> [@sgaure](#):
>
> ```julia-auto
> fun() do
> a = 14
> end
> 
> ```
> 
> is semantically equivalent to
> 
> ```julia-auto
> function someuniquename() 
> a = 14
> end
> fun(someuniquename)
> 
> ```

Now I have owned a deeper understanding. Therefore share my opinion:

The problem with `do` syntax is that it has an underlying unintuitive implication

- passing the function defined in `do` block as the first argument

Therefore the odds are that

> [@sgaure](#):
>
> the do-block is never executed.

But in sheer appearance,

```julia-auto
fun() do
    a = 14
end

```

seems to suggest that `a = 14` is **do** ne at that line.

I browsed some discussions and find that there are also people who don’t get used to using `do` block. e.g. [here](https://discourse.julialang.org/t/boxing-obvious-cases-where-the-type-is-clear/107192/5).

So we can write

```julia
local function af()
    a = 14
end
fun(af)

```

in place of any `do` syntax.

---

_[View the full topic](https://discourse.julialang.org/t/will-my-variable-be-modified-in-a-do-block-very-subtle-to-anticipate/131124)._
