<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="290487" data-post-id="290487">
  <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>But I have another solution and that is to write my own <code>import</code> (say <code>import_plus</code>) that reuses <code>import</code> in full but adds the <code>:override</code> option, that will do all the magic that I mentioned so the user does not need to this on their own or <code>use</code> the library.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290487" 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/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-290487" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290487"
                     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 #21"></div>
  </section>
</div>
    <div class="postbit" id="290511" data-post-id="290511">
  <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="21" 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>Nope. Sounds like I am just challenging certain predetermined aspects of the current version of the language. So?</p>
</blockquote>
</aside>
<p>Sorry, but I do not see this good. In same way someone may challenging <code>Ruby</code>-like syntax (<code>do … end</code> notation) or functional programming and what the community should reply for such a message? Well … you are free to use other languages or write your own?</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="21" 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>Where did I mentioned 3 or 4 arguments?</p>
</blockquote>
</aside>
<p>Ok, so … you are using naming without understanding what it means? As before non-unary operators have 2 arity. <code>different arity</code> are <strong>your</strong> words. Now see the definition of <a href="https://en.wikipedia.org/wiki/Arity" rel="noopener nofollow ugc">arity</a>. As in wikipedia the arity is <strong>number of arguments</strong>, but somehow you changed it to <code>freedom in overriding</code>. What’s more interesting you <strong>have</strong> this freedom as you are overriding operator, but instead you have conflict between two libraries. <img src="https://forum.elixirforum.com/images/emoji/apple/exploding_head.png?v=15" title=":exploding_head:" class="emoji" alt=":exploding_head:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="21" 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>Nothing is written in stone.</p>
</blockquote>
</aside>
<p>In fact <strong>it is</strong> and this is terribly important in programming. Before next major version (<code>2.x</code>) of <code>Elixir</code> we can expect new features and not changing behaviour of current ones. If that would not be a case upgrading between every <code>Elixir</code> release would be like a hell as every time you would need to update all of your projects (from pet project up to production ones) in order to make them work in new version.</p>
<p>There is even no schedule plans for <code>2.x</code> version of <code>Elixir</code> and to replace language basics you would need to convince not just maintainers, but also the whole community. So far you have no likes or replies like <code>I also have such problem</code> and therefore for now it looks like that would be a change for just one person for just one use case in which you have other ways to solve conflict problem.</p>
<p>It’s not like that community does not consider changes in language, but just for example say … When last time you have used static types in <code>Elixir</code>? Even if community is willing to consider adding this the topic have many years. Every change of behaviour would affect <strong>whole community</strong> and not only you. It’s not likely such changes would be delivered quickly <strong>if any</strong>.</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="21" 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>What do you mean by weird behavior?</p>
</blockquote>
</aside>
<p>Our community is rather used that some library could override something from <code>Kernel</code> (like <code>def</code> in components), but I do not remember a case when one library changed other one. Of course there are libraries that extends other libraries in many ways, but they are not overriding their functions/macros. For you it’s a topic like anyone else, but for others it’s rather something new. If it would not be new your posts would be merged with existing topic or this topic would be closed mentioning that there is a similar one or somebody would link to existing solutions working already in production.</p>
<aside class="quote no-group" data-username="DaAnalyst" data-post="21" 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>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?</p>
</blockquote>
</aside>
<p>Never heard about such case. It’s rather use <code>B</code> instead of <code>A</code> and not override <code>A</code> to make <code>B</code> work. If you have shared code simply use it in both <code>A</code> and <code>B</code> and let them define their own function/macros. I completely do not see a use case for what you are looking for.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Shared do
  defmacro __using__(_opts \\ []) do
    quote do
      def shared, do: :ok
    end
  end
end

defmodule A do
  defmacro __using__(_opts \\ []) do
    quote do
      use Shared
      def sample, do: :a
    end
  end
end

defmodule B do
  defmacro __using__(_opts \\ []) do
    quote do
      use Shared
      def sample, do: :b
    end
  end
end

defmodule Example1 do
  use A

  def run do
    IO.inspect(shared())
    IO.inspect(sample())
  end
end

defmodule Example2 do
  use B

  def run do
    IO.inspect(shared())
    IO.inspect(sample())
  end
end

Example1.run()
# :ok
# :a
Example2.run()
# :ok
# :b
</code></pre>
<aside class="quote no-group" data-username="DaAnalyst" data-post="22" 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>write my own <code>import</code></p>
</blockquote>
</aside>
<p>As before <code>import</code> is not a macro like those you write. It’s expanded by compiler. Do you really expect to rewrite compiler for just one case?</p>
<p>Think that everyone would do like you. Every library would need to maintain their own compiler in fact it would be like every library would have it’s own variation (slang?) of language. This is just a crazy idea. Alternatively every library request a change to <code>Elixir</code> language.. It would become a dumpster.</p>
<p>This is why <strong>by default</strong> developer should not think <code>how I could change the language to make my code work</code> especially if <strong>you have</strong> alternative ways to make your library work.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290511" 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/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-290511" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290511"
                     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 #22"></div>
  </section>
</div>
    <div class="postbit" id="290513" data-post-id="290513">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="LostKobrakai" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/LostKobrakai/120/3072_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  LostKobrakai
                  </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="1" 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>
<pre data-code-wrap="elixir"><code class="lang-elixir">2 * %{ a: 1}
# =&gt; MyLibrary passes it to the whatever prior library overriding `*` i.e. OtherLibrary and OtherLibrary does its  job
2 * [ a: 1]
# =&gt; MyLibrary does its job
2 * 2
# =&gt; 4 (MyLibrary passes it to OtherLibrary which passes it to Kernel)
</code></pre>
</blockquote>
</aside>
<p>There’s a simple solution to that imo:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">OtherLibrary.*(2, %{a: 1})
MyLibrary.*(2, [a: 1])
Kernel.*(2, 2)
</code></pre>
<p>No guesswork involved. No fallback logic needed. Each function can properly error if their inputs are incorrect. Yes you’d not use the syntax sugar you usually get with operators, but to me that’s a worthwhile tradeoff for the benefits.</p>
<p>But I’d imagine you’re still looking for that syntax sugar in the solution:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def main(multiplier) do
  mult_map(multiplier)
  mult_keyword(multiplier)
  multiplier * 2
end

defmap mult_map(multiplier) do
  multiplier * %{a: 1}
end

defkeyword mult_keyword(multiplier) do
  multiplier * %{a: 1}
end
</code></pre>
<p>This would mimic the <code>defn</code> approach you see in Nx. That one allows putting elixir code in a completely separate context (tensor calculations in the case of Nx), but importantly it puts it in just a single known context. Again no guesswork or surprises, no fallback logic, but still the ability to write elixir code with normal operator syntax and still have things work.</p>
<p>I wouldn’t suggest that as the default answer to overlapping operator overloading/overwriting of libraries, but it’s an option where extended code needs to work with overloaded operators without juggling imports.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290513" 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/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-290513" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290513"
                     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 #23"></div>
  </section>
</div>
    <div class="postbit" id="290516" data-post-id="290516">
  <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="23" 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>Well … you are free to use other languages or write your own?</p>
</blockquote>
</aside>
<p>I think I’ve heard this argument before, but it was about making one’s own Twitter. Can’t say it aged well for the proponents.</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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>Sorry, but I do not see this good. In same way someone may challenging <code>Ruby</code>-like syntax (<code>do … end</code> notation) or functional programming and what the community should reply for such a message? Well … you are free to use other languages or write your own?</p>
</blockquote>
</aside>
<p>How else do you think a technology evolves? A genuine question.</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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>Ok, so … you are using naming without understanding what it means? As before non-unary operators have 2 arity. <code>different arity</code> are <strong>your</strong> words. Now see the definition of <a href="https://en.wikipedia.org/wiki/Arity" rel="noopener nofollow ugc">arity</a>.</p>
</blockquote>
</aside>
<p>Yes, different arity in terms of 1 instead of 2. I already gave you the examples.</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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>What’s more interesting you <strong>have</strong> this freedom as you are overriding operator, but instead you have conflict between two libraries</p>
</blockquote>
</aside>
<p>That was a digression. If in doubt, feel free to re-read the entire exchange above. And I do not have any conflict between two libraries. In face, the whole discussion was initiated because I didn’t want to have one in the future.</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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 that would not be a case upgrading between every <code>Elixir</code> release would be like a hell as every time you would need to update all of your projects (from pet project up to production ones)</p>
</blockquote>
</aside>
<p>Tell me about it. Been with LiveView since its v0.4 <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"> PS. just so you don’t get into formalities again, I am aware that 0.x releases are usually volatile with plenty of breaking changes and that a major release should hold on to its interfaces (for the purity of expression sake, may I say interfaces or you’ll find it formally unacceptable again because words have meanings and there are no formal interface constructs in Elixir? )</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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>There is even no schedule plans for <code>2.x</code> version of <code>Elixir</code> and to replace language basics you would need to convince not just maintainers, but also the whole community</p>
</blockquote>
</aside>
<p>I don’t need to. That’s why I can write my own libraries.</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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 last time you have used static types in <code>Elixir</code></p>
</blockquote>
</aside>
<p>IMO Elixir does not need a static typing.</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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 it would not be new your posts would be merged with existing topic or this topic would be closed mentioning that there is a similar one or somebody would link to existing solutions working already in production.</p>
</blockquote>
</aside>
<p>Ever hear of precedents being drivers of innovation/change)?</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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>Our community is rather used that some library could override something from <code>Kernel</code> (like <code>def</code> in components),</p>
</blockquote>
</aside>
<p>See the Mark Twain’s quote at the end.</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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>Never heard about such case.</p>
</blockquote>
</aside>
<p>So?</p>
<aside class="quote no-group" data-username="Eiji" data-post="23" 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>I completely do not see a use case for what you are looking for.</p>
</blockquote>
</aside>
<p>I got that.</p>
<aside class="quote no-group quote-modified" data-username="Eiji" data-post="23" 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>Every library would need to maintain their own compiler in fact it would be like every library would have it’s own variation (slang?) of language. This is just a crazy idea. Alternatively every library request a change to <code>Elixir</code> language… It would become a dumpster.</p>
</blockquote>
</aside>
<p>My view is that every single piece of open source technology is a foundation for a market of ideas. It is not what is academically correct that should prevail but what is proven to be most useful over time. I love Elixir as it is now, but there are things to consider improving. Not saying that my ideas should necessarily be the ones that are accepted or approved. Maybe the ideas of others address a bigger scope and thus solve my problems automatically. Only time will tell.</p>
<p>Lastly, a word of advice to you, buddy, in three bullet points:</p>
<ul>
<li>No hard feelings</li>
<li>Whenever you find yourself on the side of the majority, <strong>it is time to reform, pause or reflect</strong>. — Mark Twain</li>
<li>Chill man, chill.</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290516" 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/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-290516" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290516"
                     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 #24"></div>
  </section>
</div>
    <div class="postbit" id="290520" data-post-id="290520">
  <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 appreciate your opinion (here and in general). But with what you just said in mind:</p>
<ol>
<li>
<p>How do you defend the position of what is typically done in libraries (or has been done up until now) when it comes to the fallback to Kernel? How come this “fallback depth of 1” is acceptable while a “fallback depth of n where n &gt;= 1” is not? An additional cost cannot be an argument, for it only occurs in a very tiny percentage of cases while the library would still mostly fallback to the Kernel implementation, but at least wouldn’t be unusable in that same tiny percentage of cases. Please bear in mind that I am talking about a very generic application that is more likely than not going to create issues (litter the code with switching the thing on/off) when used together with another hypothetical library with the same operator override in that miniscule number of cases.</p>
</li>
<li>
<p>You’re right about the syntactic sugar. To me, personally, this minimalistic syntactic sugar style is one of the reasons why I like Elixir so much. And because I like it so much, I want to be able to expand on it myself, not just use the existing ones. The libraries I write now are all about that. They do not introduce new ways of computing things - they make things simpler to write and easier to read (assuming the acceptance of the localized syntax extension).</p>
</li>
</ol>
<p>Btw, the problem with your second approach is that in my case it is not applicable. The reason why I am using operators (and not standard macros) in the first place is to take precedence over the evaluation of the arguments. If there was a way to do this with standard macros, I would most likely use them instead.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290520" 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/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-290520" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290520"
                     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 #25"></div>
  </section>
</div>
    <div class="postbit" id="290521" data-post-id="290521">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="LostKobrakai" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/LostKobrakai/120/3072_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  LostKobrakai
                  </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="26" 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>How come this “fallback depth of 1” is acceptable while a “fallback depth of n where n &gt;= 1” is not?</p>
</blockquote>
</aside>
<p>Can you expand on that? I personally don’t advocate for any fallback to <code>Kernel.</code> anywhere. You might be confusing this with Kernel implicitly being imported, but that’s (at least technically) not a fallback. You still either have the operator be defined by <code>Kernel</code> or you have it defined by whatever else you import.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290521" 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/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-290521" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290521"
                     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 #26"></div>
  </section>
</div>
    <div class="postbit" id="290522" data-post-id="290522">
  <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>Most libraries do something like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def doit( whateverpattern) do
 # library behavior
end

def doit( other) do
  &lt;oprerator&gt; other
  # or
  #Kernel.&lt;operator&gt; other
end
</code></pre>
<p>That’s what I refer to “fallback depth of 1”.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290522" 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/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-290522" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290522"
                     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 #27"></div>
  </section>
</div>
    <div class="postbit" id="290523" data-post-id="290523">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>For that I think my argument applies as well. Fallbacks hide boundries and make input validation tricky. It’s imo just complexity, which makes understanding code more difficult. That’s also a point for your previous comment. There’s a difference between easy to read and easy to understand. Imo the latter is more important than the former. It might seem nice to just be able to multiply whatever, but it’ll be much more complex if it doesn’t work as expected and you need to get an understanding of why that’s the case if you’re dealing with a matroschka doll of overloads/fallbacks.</p>
<p>That’s also very close to the composition over inheritance argument btw.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290523" 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/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-290523" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290523"
                     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 #28"></div>
  </section>
</div>
    <div class="postbit" id="290524" data-post-id="290524">
  <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="LostKobrakai" data-post="29" 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/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>There’s a difference between easy to read and easy to understand. Imo the latter is more important than the former.</p>
</blockquote>
</aside>
<p>Agreed on difference and agreed on understanding. However, I find understandable more subjective than readable so, personally, I tend to lean towards to prioritizing readable.</p>
<aside class="quote no-group" data-username="LostKobrakai" data-post="29" 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/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>if it doesn’t work as expected and you need to get an understanding of why that’s the case if you’re dealing with a matroschka doll of overloads/fallbacks.</p>
</blockquote>
</aside>
<p>Clear. The accountability assumed here <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="LostKobrakai" data-post="29" 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/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>That’s also very close to the composition over inheritance argument btw.</p>
</blockquote>
</aside>
<p>Also true.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="290524" 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/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-290524" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="290524"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>