# Syntax: How to write a cleaner code for many composed computations

**URL:** <https://discourse.julialang.org/t/syntax-how-to-write-a-cleaner-code-for-many-composed-computations/92211>\
**Category:** New to Julia\
**Created:** [December 28, 2022, 7:07am UTC](https://discourse.julialang.org/t/syntax-how-to-write-a-cleaner-code-for-many-composed-computations/92211 "2022-12-28T07:07:43Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [December 30, 2022, 1:25am UTC](https://discourse.julialang.org/t/syntax-how-to-write-a-cleaner-code-for-many-composed-computations/92211/12 "2022-12-30T01:25:14Z")

</div>

> [@jar1](#):
>
> What’s the point of using `,` there instead of `;`? Seems like the wrong notation

The comma-delimited assignments in the “head” of the `let` statement behave differently from assignments in its body.

The behavior of `let` statements is like function definitions, where the head is like the argument list for a function with default values:

```julia
a=1; d=0

let a=a, b=2, c=a+b
    d=a+b+c
    d^2
end #-> 36

# is like
( (a=a, b=2, c=a+b) -> begin
    d=a+b+c
    d^2
end)() #-> 36

d == 0 #-> true

```

The variable scoping rules are the same.

The difference between assignments in the head and assignments in the body becomes starker for nested local scopes:

```julia
let a=1
    (let a=10; a end, a)
end #-> (10, 1)
# versus
let a=1
    (let; a=10; a end, a)
end #-> (10, 10)

```

note, again, that functions share these same behaviors; the key differences with `let` being the absence of a capture or boxing (and no extra compile time), and `return` behaves differently.

Interestingly, the [example in the docs](https://docs.julialang.org/en/v1/base/base/#let) is erroneous (it’s probably showing an intended feature that’s not implemented yet).

---

_[View the full topic](https://discourse.julialang.org/t/syntax-how-to-write-a-cleaner-code-for-many-composed-computations/92211)._
