# Wondering if extending Base: max with max(a) = max(a...) would be safe?!

**URL:** <https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885>\
**Category:** General Usage\
**Created:** [March 12, 2025, 6:31pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885 "2025-03-12T18:31:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![askvorts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/askvorts/32/7120_2.png) [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Post date:** [March 12, 2025, 6:31pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885/1 "2025-03-12T18:31:09Z")

</div>

So I am wondering if

```julia
import Base: max
max(a) = max(a...)
export max

```

would be safe, after all I am extending the “concept” to vectors or NTuples. Bu then it may well be a rather stupid thing to do, and have serious side effects that I am unaware…

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [March 12, 2025, 6:32pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885/2 "2025-03-12T18:32:50Z")

</div>

Splatting (`a...`) is slow for long arrays. There is `maximum` that does what you implement.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 12, 2025, 6:44pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885/3 "2025-03-12T18:44:54Z")

</div>

> [@askvorts](#):
>
> it may well be a rather stupid thing to do

Extending `Base.max` in this way would be [“type piracy”](https://docs.julialang.org/en/v1/manual/style-guide/#avoid-type-piracy), which is typically a bad idea because it has side effects on unrelated code. (Aside from the fact that this is what `maximum` is for, or that splatting large collections is bad.)

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [March 12, 2025, 7:37pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885/4 "2025-03-12T19:37:46Z")

</div>

`reduce(max, xs)` also works for this.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [March 12, 2025, 7:53pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885/5 "2025-03-12T19:53:01Z")

</div>

It’s also quite confused in terms of its own meaning. What should `max([[1,2]])` be? What about `max([[1,2],[3,4]])`? Or `max([[[1,2]]])`?

This is precisely why Julia separates out the concepts of `max` from `maximum`.

---

<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:** [March 12, 2025, 8:20pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885/6 "2025-03-12T20:20:38Z")

</div>

And to mention the last edge case: What should `max([])` (which would result in `max()`) be?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 12, 2025, 10:02pm UTC](https://discourse.julialang.org/t/wondering-if-extending-base-max-with-max-a-max-a-would-be-safe/126885/7 "2025-03-12T22:02:45Z")

</div>

> [@Sukera](#):
>
> And to mention the last edge case: What should `max([])` (which would result in `max()`) be?

Presumaby the same as `maximum` of an empty collection, which currently throws; see also [Extend the domain of maximum and minimum to include empty collection? - #3 by klacru](https://discourse.julialang.org/t/extend-the-domain-of-maximum-and-minimum-to-include-empty-collection/5135/3)
