# Dot position to broadcast: f. vs .+

**URL:** <https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978>\
**Category:** General Usage\
**Created:** [May 29, 2017, 3:22pm UTC](https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978 "2017-05-29T15:22:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthieu](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Post date:** [May 29, 2017, 3:22pm UTC](https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978/1 "2017-05-29T15:22:00Z")

</div>

I like the new . syntax to broadcast but I have a question about the position of the dot .  
Why is the syntax to add elementwise.+ while the syntax to apply a function elementwise is f. ? Is not it inconsistent?

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [May 29, 2017, 3:26pm UTC](https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978/2 "2017-05-29T15:26:16Z")

</div>

There are historical reasons, the generic `<f>.(args)` syntax is new (v0.5 IIRC), and various `.<op>` had been added individually as far back as v0.3 IIRC, also, the `.<op>` ones are all infix.  
You can find a lot of discussion about the design decisions of this on GitHub.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 29, 2017, 3:26pm UTC](https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978/3 "2017-05-29T15:26:29Z")

</div>

> [@matthieu](#):
>
> Why is the syntax to add elementwise.+ while the syntax to apply a function elementwise is f. ? Is not it inconsistent?

`f.` makes sense for function calls. `.*` is backwards compatible with previous versions of Julia and MATLAB. I agree that for consistency it would be nice to have `*.`

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 29, 2017, 3:34pm UTC](https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978/4 "2017-05-29T15:34:33Z")

</div>

We already have `*.`. It works as function call.

The `f.(...)` is also consistent in that it’s a broadcast function call, i.e. `.()`.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 29, 2017, 3:41pm UTC](https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978/5 "2017-05-29T15:41:36Z")

</div>

> [@yuyichao](#):
>
> We already have \*… It works as function call.

```julia
julia> rand(4) *. rand(4)
ERROR: syntax: invalid identifier name "."

julia> (*).(rand(4),rand(4))
4-element Array{Float64,1}:
 0.570417
 0.464287
 0.0955142
 0.132438

```

That’s not the same thing. I still wonder why the binary version should have the `.` in front.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 29, 2017, 3:54pm UTC](https://discourse.julialang.org/t/dot-position-to-broadcast-f-vs/3978/6 "2017-05-29T15:54:42Z")

</div>

Because you also don’t write `a f. b` for normal functions.

And as mentioned above, the operator have `.` in the front because function call broadcast syntax also have `.` in the front.
