<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="290462" data-post-id="290462">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Eiji" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Eiji/120/36743_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Eiji
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="DaAnalyst" data-post="10" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>There’s a scarcity of custom operators, unary in particular.</p>
</blockquote>
</aside>
<p>What unary operator could be added? So far I can see only <code>$</code> free. The problem is that <code>Elixir</code> core does use most of ASCII characters and there is no much place here.</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="10" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>It wouldn’t hurt if <code>import</code> had an additional option (say <code>:not</code>) to un-import some but not import all other functions/macros.</p>
</blockquote>
</aside>
<p>That would not happen. Firstly I did not saw anyone else needing this and because of it <code>Elixir</code> core team would most probably not accept it. Also at least for me it looks like you are trying to overcomplicate the problem and you should search for an easier solution to do same/similar thing.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290462" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-290462" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290462"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="290463" data-post-id="290463">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The specifics matter here a lot though honestly. Your example is about operator overloading which really ought to be done very sparingly as it is not zero cost. Do you have other concrete examples where this is an issue? Are these your libraries or external ones?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290463" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-290463" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290463"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="290464" data-post-id="290464">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DaAnalyst" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DaAnalyst
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<ol>
<li>
<p><code>$</code>, <code>~</code> and all special forms being overridable operators (can’t tell if it is easily or anyhow doable though). Also, being able to define different arity for non-unary operators to become ones. PS. I am aware that <code>~</code> is used for sigils, but nevertheless.</p>
</li>
<li>
<p>It’s their right to decide whatever they want. I expressed my opinion and I think it’s valid.</p>
</li>
</ol>
<p>Besides, do note that I am using macros and not functions there. It’s the only way to take precedence to re-interpret the otherwise special forms.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290464" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-290464" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290464"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="290465" data-post-id="290465">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DaAnalyst" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DaAnalyst
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I agree that it comes at an additional cost <em>unless</em> there’s a way to quote the fallback to the original operator (which was my intention, btw).</p>
<p>In my example above the “OtherLibrary” is an external one that I don’t have an influence over. It’s a hypothetical library. My intention was (as the title suggests) to make my library (that overrides a unary operator) resilient and flexible to situations where the user is also using another such library that I do not know of. That’s all to it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290465" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-290465" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290465"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="290466" data-post-id="290466">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="al2o3cr" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/120/3457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  al2o3cr
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="DaAnalyst" data-post="10" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>There’s a scarcity of custom operators, unary in particular.</p>
</blockquote>
</aside>
<p>I’m less-opposed to custom operators than most, but IMO if you’ve got different overrides for the same operator <em>overriding each other</em> you may want to consider a different design.</p>
<p>Setting the specifics of operators aside, it sounds like what you want is something where you can <code>import</code> heads for <strong>one</strong> function from <strong>multiple</strong> modules:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># HYPOTHETiCAL: THIS CODE DOES NOT WORK - SEE NOTES BELOW

defmodule ImplOne do
  def some_fun(x) when is_list(x), do: IO.puts("list!")
end

defmodule ImplTwo do
  def some_fun(x) when is_map(x), do: IO.puts("map!")
end

defmodule Demo do
  import ImplOne
  import ImplTwo

  def do_stuff do
    some_fun([1,2,3])
    some_fun(%{a: 1})
  end
end
</code></pre>
<p>This currently complains:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">** (CompileError) iex:11: function some_fun/1 imported from both ImplTwo and ImplOne, call is ambiguous
    (elixir 1.14.0) src/elixir_dispatch.erl:149: :elixir_dispatch.expand_import/7
    (elixir 1.14.0) src/elixir_dispatch.erl:119: :elixir_dispatch.dispatch_import/6
    (elixir 1.14.0) src/elixir_expand.erl:567: :elixir_expand.expand_block/5
    (elixir 1.14.0) src/elixir_expand.erl:40: :elixir_expand.expand/3
    (elixir 1.14.0) src/elixir_clauses.erl:37: :elixir_clauses.def/3
    (elixir 1.14.0) src/elixir_def.erl:197: :elixir_def."-store_definition/10-lc$^0/1-0-"/3
    iex:6: (file)
</code></pre>
<p>TBH this style of importing reminds me of the worst parts of OO, where you end up playing “your method is in another castle” through twelve classes all named <code>Base</code>.</p>
<hr>
<aside class="quote no-group" data-username="DaAnalyst" data-post="11" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>But if you’re developing something of a very generic purpose that can be applied all over your code base</p>
</blockquote>
</aside>
<p>If you’re doing something like this codebase-wide, I’d recommend combining all the relevant plumbing into one module that gets <code>use</code>d consistently. That module may not be pretty, but it will be <em>centralized</em> - the thing you want to avoid is having your codebase littered with slightly-different sets of operators etc in different modules.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290466" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-290466" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290466"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="290467" data-post-id="290467">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DaAnalyst" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DaAnalyst
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I agree with you completely, but that’s not the point here. I explained my concerns here:</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="15" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>In my example above the “OtherLibrary” is an external one that I don’t have an influence over. It’s a hypothetical library. My intention was (as the title suggests) to make my library (that overrides a unary operator) resilient and flexible to situations where the user is also using another such library that I do not know of. That’s all to it.</p>
</blockquote>
</aside> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290467" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-290467" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290467"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="290471" data-post-id="290471">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Eiji" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Eiji/120/36743_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Eiji
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="DaAnalyst" data-post="14" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p><code>$</code>, <code>~</code> and all special forms being overridable operators (can’t tell if it is easily or anyhow doable though).</p>
</blockquote>
</aside>
<p>The question was what unary operator could be <strong>added</strong> - overriding is not adding. <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20">  That’s important to say as you only repeat after me one character <code>$</code>, so in fact you confirm there is not much to add here and definitely not many things.</p>
<p>You need to understand that any overrides and multiple meaning of same operators is more confusing than helping especially when we are talking about <code>%</code> as every new developer would think about maps in first place. Also <code>SpecialForms</code> naming is not random. If you really want to write for example your own <code>for</code> special form then you would need to go outside <code>Elixir</code>.</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="14" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>Also, being able to define different arity for non-unary operators to become ones.</p>
</blockquote>
</aside>
<p>But then those would no longer be operators. <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="14" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>I expressed my opinion and I think it’s valid.</p>
</blockquote>
</aside>
<p>When starting with programming and <code>Elixir</code> I have also expressed many things and found myself that many of them does not makes sense at all only because I did not understand something.</p>
<p>Let’s go back to your question … If you really want to go this way then consider splitting your macros.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Example do
  use First
  use Second
  import First, only: [-: 1]
  # or
  # import Second, only: [-: 1]
end
</code></pre>
<p>This is simplest way without going around. The developer could decide which function/macro should be imported. Also it’s highly recommended to prefer <code>import</code> in favor of <code>use</code> when everything you do is to <code>import</code> functions/macros.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290471" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-290471" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290471"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="290472" data-post-id="290472">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DaAnalyst" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DaAnalyst
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Eiji" data-post="18" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>The question was what unary operator could be <strong>added</strong> - overriding is not adding. <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"> That’s important to say as you only repeat after me one character <code>$</code>, so in fact you confirm there is not much to add here and definitely not many things.</p>
</blockquote>
</aside>
<p>I meant functionally ‘added’ not added in literal sense.</p>
<aside class="quote no-group" data-username="Eiji" data-post="18" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>If you really want to write for example your own <code>for</code> special form then you would need to go outside <code>Elixir</code>.</p>
</blockquote>
</aside>
<p>Personally, I had no intention of overriding <code>for</code>. The special forms that I was referring to are: <code>^</code>, <code>&amp;</code>, <code>.</code>, <code>:</code>, <code>=</code>.</p>
<aside class="quote no-group" data-username="Eiji" data-post="18" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>But then those would no longer be operators.</p>
</blockquote>
</aside>
<p>Don’t agree with that. For instance <code>**</code> can just as well be interpreted as a unary operator meaning same as <code>x ** 2</code>, to name one. Not to mention (Godforbid) the <code>++</code> and <code>--</code> as used in C/C++. Not operators?</p>
<aside class="quote no-group" data-username="Eiji" data-post="18" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>When starting with programming and <code>Elixir</code> I have also expressed many things and found myself that many of them does not makes sense at all only because I did not understand something.</p>
</blockquote>
</aside>
<p>Me too. First in 1988 with C, then in 1998 with Java, then .., and then in 2019 with Elixir. Must say though that for Javascript at least, I still find many of my old remarks valid <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="Eiji" data-post="18" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>This is simplest way without going around. The developer could decide which function/macro should be imported. Also it’s highly recommended to prefer <code>import</code> in favor of <code>use</code> when everything you do is to <code>import</code> functions/macros.</p>
</blockquote>
</aside>
<p>Yes, this is a valid approach, but I don’t like it (the “batteries not included” style). But that’s just me. Turns out I’ll be most likely writing that “cumbersome” (yet compile-time so it doesn’t count as much) piece of code that collects all not previously imported functions and macros only to exclude them along with the one for my operator.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290472" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-290472" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290472"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="290479" data-post-id="290479">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Eiji" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Eiji/120/36743_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Eiji
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="DaAnalyst" data-post="19" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>I meant functionally ‘added’ not added in literal sense.</p>
</blockquote>
</aside>
<p>I don’t get “functionally added”. They exists as a part of language. They are named “special” for purpose.</p>
<blockquote>
<p>Special forms are the basic building blocks of Elixir, and therefore cannot be overridden by the developer.</p>
</blockquote>
<p>It’s like you want to replace foundations of house and expect that nothing bad would happen. Special forms are not even macros like the ones you are writing. They are expanded by compiler and this is a completely different topic.</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="19" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>Don’t agree with that.</p>
</blockquote>
</aside>
<p>wait, wait</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="14" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>Also, being able to define different arity for non-unary operators to become ones.</p>
</blockquote>
</aside>
<p>Non-unary operators like <code>a = b</code> have always 2 arity and you wrote about <strong>different arity</strong>. How do you see 3 or 4-arity operator?</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="19" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/d/278dde/48.png" class="avatar"> DaAnalyst:</div>
<blockquote>
<p>Yes, this is a valid approach, but I don’t like it (the “batteries not included” style). But that’s just me. Turns out I’ll be most likely writing that “cumbersome” (yet compile-time so it doesn’t count as much) piece of code that collects all not previously imported functions and macros only to exclude them along with the one for my operator.</p>
</blockquote>
</aside>
<p>The problem is that you would need to describe that weird behaviour to all developers using you library. The <code>inspecting</code> is only in examples. Most probably you would not log them and that would be extremely confusing.</p>
<p>The good practice is to write a code and be able to describe what it does even if you stop touching it for let’s say 6 months. In your case the developer would need to remind which macros are overriding operator and in which order. Now think that you decide to change behaviour of your library and this time you want to take operator from first macro. If so would happen nobody maybe except maintainers would follow the whole process.</p>
<p>Hiding everything is not always the best way and in some cases it may be seen as a bad practice.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290479" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-290479" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290479"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="290486" data-post-id="290486">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DaAnalyst" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DaAnalyst
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Eiji" data-post="20" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>It’s like you want to replace foundations of house and expect that nothing bad would happen. Special forms are not even macros like the ones you are writing.</p>
</blockquote>
</aside>
<p>Nope. Sounds like I am just challenging certain predetermined aspects of the current version of the language. So?</p>
<aside class="quote no-group" data-username="Eiji" data-post="20" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>How do you see 3 or 4-arity operator?</p>
</blockquote>
</aside>
<p>Where did I mentioned 3 or 4 arguments? I just wanted a little more freedom in overriding the operators. And if those special forms are implemented as they are now (in theory) it doesn’t mean they need to stay that way. It’s a software for God’s sake. Nothing is written in stone.</p>
<aside class="quote no-group" data-username="Eiji" data-post="20" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>The problem is that you would need to describe that weird behaviour to all developers using you library.</p>
</blockquote>
</aside>
<p>What do you mean by weird behavior? “If you’re using another library that overrides the operator X, just use this one after the <code>import/use</code> of the former and it will all work.” Is that a weird, hard to maintain behavior?<br>
The only scenario in which my approach would not work is if the other library matched on the very same value patterns that my operator override matches and this would be documented. In your case, it would take turning one off to turn the other on even if there’s never such a case, only to accommodate the very fact that you’re overloading the same operator, while mine still leaves the same option to the user without mandating it to them for the 99.9999% of the cases =&gt; If my <code>use</code> just imports what it imports, then the user is also free to import it manually the way you suggest, but if I don’t make what I said I would, then it becomes the only option in spite of an ultra miniscule and still warned about chance of a conflict.</p>
<aside class="quote no-group" data-username="Eiji" data-post="20" data-topic="56290">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>Hiding everything is not always the best way and in some cases it may be seen as a bad practice.</p>
</blockquote>
</aside>
<p>Yes, I agree with that. Part of the reason I went from OO to all-in functional.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290486" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/fallback-to-nearest-prior-imported-library-module-and-not-necessarily-kernel-when-overriding-an-operator/56290/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-290486" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290486"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/56290/load_more?page=3">Load more posts (9 remaining)</a>
</div></template></turbo-stream>