<p dir="auto">I'm currently using Julia 1.7.0 and discovered some weird behaviour between <code class="notranslate">minimum</code> and <code class="notranslate">Set{CartesianIndex}</code></p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
  JULIA_LOAD_PATH = /home/doudou/Documents/Code/AdventofCode:@:@v#.#:@stdlib"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">versioninfo</span>()
Julia Version <span class="pl-c1">1.7</span>.<span class="pl-c1">0</span>
Commit <span class="pl-c1">3</span>bf9d17731 (<span class="pl-c1">2021</span><span class="pl-k">-</span><span class="pl-c1">11</span><span class="pl-k">-</span><span class="pl-c1">30</span> <span class="pl-c1">12</span><span class="pl-k">:</span><span class="pl-c1">12</span> UTC)
Platform Info<span class="pl-k">:</span>
  OS<span class="pl-k">:</span> Linux (x86_64<span class="pl-k">-</span>pc<span class="pl-k">-</span>linux<span class="pl-k">-</span>gnu)
  CPU<span class="pl-k">:</span> <span class="pl-c1">Intel</span>(R) <span class="pl-c1">Core</span>(TM) i7<span class="pl-k">-</span><span class="pl-c1">8750</span>H CPU @ <span class="pl-c1">2.20</span>GHz
  WORD_SIZE<span class="pl-k">:</span> <span class="pl-c1">64</span>
  LIBM<span class="pl-k">:</span> libopenlibm
  LLVM<span class="pl-k">:</span> libLLVM<span class="pl-k">-</span><span class="pl-c1">12.0</span>.<span class="pl-c1">1</span> (ORCJIT, skylake)
Environment<span class="pl-k">:</span>
  JULIA_LOAD_PATH <span class="pl-k">=</span> <span class="pl-k">/</span>home<span class="pl-k">/</span>doudou<span class="pl-k">/</span>Documents<span class="pl-k">/</span>Code<span class="pl-k">/</span>AdventofCode<span class="pl-k">:</span>@:<span class="pl-c1">@v</span><span class="pl-c"><span class="pl-c">#</span>.#:@stdlib</span></pre></div>
<p dir="auto">The minimal reproducible code is the following:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="s = Set(CartesianIndices((2, 2)))
#Set{CartesianIndex{2}} with 4 elements:
#  CartesianIndex(2, 1)
#  CartesianIndex(1, 1)
#  CartesianIndex(2, 2)
#  CartesianIndex(1, 2)

minimum(s)
#CartesianIndex(1, 1)

delete!(s, CartesianIndex(1, 1))
#Set{CartesianIndex{2}} with 3 elements:
#  CartesianIndex(2, 1)
#  CartesianIndex(2, 2)
#  CartesianIndex(1, 2)

minimum(s)
#CartesianIndex(1, 1)

minimum(s) ∈ s
#false

pop!(s)
#Any element of s randomly

minimum(s) ∈ s
#true"><pre class="notranslate">s <span class="pl-k">=</span> <span class="pl-c1">Set</span>(<span class="pl-c1">CartesianIndices</span>((<span class="pl-c1">2</span>, <span class="pl-c1">2</span>)))
<span class="pl-c"><span class="pl-c">#</span>Set{CartesianIndex{2}} with 4 elements:</span>
<span class="pl-c"><span class="pl-c">#</span>  CartesianIndex(2, 1)</span>
<span class="pl-c"><span class="pl-c">#</span>  CartesianIndex(1, 1)</span>
<span class="pl-c"><span class="pl-c">#</span>  CartesianIndex(2, 2)</span>
<span class="pl-c"><span class="pl-c">#</span>  CartesianIndex(1, 2)</span>

<span class="pl-c1">minimum</span>(s)
<span class="pl-c"><span class="pl-c">#</span>CartesianIndex(1, 1)</span>

<span class="pl-c1">delete!</span>(s, <span class="pl-c1">CartesianIndex</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>))
<span class="pl-c"><span class="pl-c">#</span>Set{CartesianIndex{2}} with 3 elements:</span>
<span class="pl-c"><span class="pl-c">#</span>  CartesianIndex(2, 1)</span>
<span class="pl-c"><span class="pl-c">#</span>  CartesianIndex(2, 2)</span>
<span class="pl-c"><span class="pl-c">#</span>  CartesianIndex(1, 2)</span>

<span class="pl-c1">minimum</span>(s)
<span class="pl-c"><span class="pl-c">#</span>CartesianIndex(1, 1)</span>

<span class="pl-c1">minimum</span>(s) <span class="pl-k">∈</span> s
<span class="pl-c"><span class="pl-c">#</span>false</span>

<span class="pl-c1">pop!</span>(s)
<span class="pl-c"><span class="pl-c">#</span>Any element of s randomly</span>

<span class="pl-c1">minimum</span>(s) <span class="pl-k">∈</span> s
<span class="pl-c"><span class="pl-c">#</span>true</span></pre></div>
<p dir="auto">This does not happens with other type (tried <code class="notranslate">Int</code> and some custom struct) inside the set and it seems a <code class="notranslate">pop!</code> puts everything back in order.</p>
<p dir="auto">Since If blocks are expressions, Julia's ternary operator is redundant since it is just a less readable alias for an if block. Furthermore, since Julia uses both : as a separate operator it leads to ambiguous parses in cases like  <code class="notranslate">whichrange()?1:2:3:4</code> (which returns 1 or 2:3:2 in Julia 0.6).</p>
<p dir="auto">Deprecating the ?: syntax in favor of just pointing people to if blocks would make the language more consistent, it would eliminate the possibility of an ambiguous parse, and it would mean that people coming from Python or Matlab would have one less new bit of syntax to learn. Using if as a ternary expression is natural enough that I don't think that having the same syntax as C is of any benefit tbh.</p>
<p dir="auto">Regarding the same tradeoff in other languages, Rust had both if expressions and ?: in beta, but deprecated ?: before 1.0. When someone put up a post-1.0 pull request in favor of adding (?:) it was overwhelmingly voted against<br>
( <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3008539" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/1698" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/1698/hovercard" href="https://github.com/rust-lang/rust/issues/1698">rust-lang/rust#1698</a><br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3015860" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/1705" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/1705/hovercard" href="https://github.com/rust-lang/rust/pull/1705">rust-lang/rust#1705</a><br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="116190286" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rfcs/issues/1362" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rfcs/issues/1362/hovercard" href="https://github.com/rust-lang/rfcs/issues/1362">rust-lang/rfcs#1362</a> ).</p>