# Problem with @which source code number of lines?

**URL:** <https://discourse.julialang.org/t/problem-with-which-source-code-number-of-lines/17128>\
**Category:** Internals & Design\
**Created:** [November 3, 2018, 10:59pm UTC](https://discourse.julialang.org/t/problem-with-which-source-code-number-of-lines/17128 "2018-11-03T22:59:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KZiemian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kziemian/32/9020_2.png) [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Post date:** [November 3, 2018, 10:59pm UTC](https://discourse.julialang.org/t/problem-with-which-source-code-number-of-lines/17128/1 "2018-11-03T22:59:40Z")

</div>

This topic is too deep in language for my, to understand what is really going on, so maybe I wrongly think that is a problem.

When you using

```julia
@which sum([1 2 3])

```

you get line `sum(a::AbstractArray) in Base at reducedim.jl:645`. This is great feature, especially when you use Jupyter, but this line is (probably) wrong. [reducedim.jl:645](https://github.com/JuliaLang/julia/blob/0d713926f85dfa3e4e0962215b909b8e47e94f48/base/reducedim.jl#L645) is inside `for` loop below `any!(r, A)` function and function `sum(a::AbstractArray)` is absent from this file. Function `sum(A::AbstractArray; dims)` is at the [line 370](https://github.com/JuliaLang/julia/blob/0d713926f85dfa3e4e0962215b909b8e47e94f48/base/reducedim.jl#L370) of this file.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [November 3, 2018, 11:06pm UTC](https://discourse.julialang.org/t/problem-with-which-source-code-number-of-lines/17128/2 "2018-11-03T23:06:14Z")

</div>

No, this position is actually correct! `sum` is one of the functions in Base that are created using `@eval`, with a mechanism used to define function interfaces with the same signature but for different functions.

Take a look:

> <https://github.com/JuliaLang/julia/blob/0d713926f85dfa3e4e0962215b909b8e47e94f48/base/reducedim.jl#L641-L652>

In this snippet, a loop is going over some fixed tuples in a list and creates a function with e.g. `sum` as the name and some method definitions with various arguments (in this example `sum(a::AbstractArray; dims=:) = _sum(a, dims)`). The definition in line 370 is just for documentation purposes (sort of like `*.h` files are used nowadays in C/C++ programming) - notice the docstring above the definition and the lack of a function body.

---

<div class="post-metadata">

**Author:** ![KZiemian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kziemian/32/9020_2.png) [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Post date:** [November 3, 2018, 11:19pm UTC](https://discourse.julialang.org/t/problem-with-which-source-code-number-of-lines/17128/3 "2018-11-03T23:19:45Z")

</div>

Thank you for explaining that, now that make more sens to me. Can you also tell me why is one place is `sum(A::AbstractArray; dims)` and in other `sum(A::AbstractArray)`?
