# Line break and indentation with where

**URL:** <https://discourse.julialang.org/t/line-break-and-indentation-with-where/12314>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 11, 2018, 9:41am UTC](https://discourse.julialang.org/t/line-break-and-indentation-with-where/12314 "2018-07-11T09:41:04Z")\
**Posts on this page:** 4\
**Page:** 1

<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 11, 2018, 9:41am UTC](https://discourse.julialang.org/t/line-break-and-indentation-with-where/12314/1 "2018-07-11T09:41:04Z")

</div>

I find that I am writing long function signatures with `where`, and wondering about the proper formatting and style. Suppose one wants to put a linebreak in

```julia
function LongConstructorName(value::T, gradient::S) where {T <: Real, S <: AbstractVector{T}}
   1+1
end

```

1. doing it before `where` is not allowed AFAICT,

2. doing it after `where`

3. the indented version is slightly better

Is there a better approach?

---

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [July 11, 2018, 9:45am UTC](https://discourse.julialang.org/t/line-break-and-indentation-with-where/12314/2 "2018-07-11T09:45:46Z")

</div>

What about?

```julia
function LongConstructorName(
    value::T, gradient::S
) where {T <: Real, S <: AbstractVector{T}}
    1+1
end

```

here doing

```julia
function LongConstructorName(
        value::T, gradient::S
    ) where {T <: Real, S <: AbstractVector{T}}
    1+1
end

```

would also probably be better.

A more extreme case, emacs indentation:

```julia
function LongConstructorName(
    value::T, gradient::S
) where {
    T <: Real, S <: AbstractVector{T}
}
    1+1
end

```

which should then also be:

```julia
function LongConstructorName(
        value::T, gradient::S
    ) where {
        T <: Real, S <: AbstractVector{T}
    }
    1+1
end

```

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 11, 2018, 10:35am UTC](https://discourse.julialang.org/t/line-break-and-indentation-with-where/12314/3 "2018-07-11T10:35:10Z")

</div>

`where` must follow the closing **`)`** of the function arglist **on the same line** as that closing paren. That `)` itself can be on the line following the final arg of the arglist, or not.

the wherefores that follow `where` should be in `{` `}` (it looks better and is easier to read, although it is not now required). That part of the function signature does not have to be on the same line.

if `function` begins in column 1, then the function declaration/specification/definition ends with `end` in column 1. None of the lines of program source text between them should start in the first column. This is long standing practice, you may prefer stepping in with 4spaces [which is most commonly used (see Base)] or some other favorite indent. Doing so makes your code much more transparent to others.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [July 11, 2018, 11:17am UTC](https://discourse.julialang.org/t/line-break-and-indentation-with-where/12314/4 "2018-07-11T11:17:38Z")

</div>

Without thinking too long about it, I would probably be inclined to do

```julia
function LongConstructorName(value::T, gradient::S) where
                            {T <: Real, S <: AbstractVector{T}}
    1+1
end

```

although I could easily see myself doing

```julia
function LongConstructorName(value::T,
                             gradient::S) where {T <: Real,
                                                 S <: AbstractVector{T}}
    1+1
end

```

just because my editor would be helpful with it.
