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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sasajuric" data-post="16" data-topic="63278">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/48/991_2.png" class="avatar"> sasajuric:</div>
<blockquote>
<p>In addition, I consider the 2nd version more flexible, because the “constant” can be provided after the implementation, which I often find better than listing various constants at the top of the file.</p>
</blockquote>
</aside>
<p>Is this also applicable to values we are setting in the <code>config.exs</code> like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">config :my_app, x: Enum.to_list(1..1_000_000)
</code></pre>
<p>And then calling for the “const”:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Foo do
  def foo, do: Application.get_env(:my_app, :x)
  def bar, do: Application.get_env(:my_app, :x)
end
</code></pre>
<p>Because this is usually the way I’m defining and using my constants..</p>
<hr>
<p>Regarding the subject of constants, I think we are already all good in Elixir and here is my 2cts (biased because of my background in C)..</p>
<p>If I do, <code>a = 2 * 3.14 * r</code>, I guess everyone will get that this is pi.. But not everyone will grab what <code>0x89504e47</code> is.. So doing <code>PNG_SIGNATURE=0x89504e47</code> is pretty sane… And that still would apply for pi <code>PI=3.14159</code> so this allows to reuse it without introducing typos.. (although for this example we have a better option of course by using <code>:math.pi()</code>)<br>
But if this was a regular variable, the risk to have it modified elsewhere in the codebase would be not null..</p>
<p>So often we use constants to make a given <strong>literal value</strong> being meaningful and to actually have it <strong>read-only</strong>.</p>
<p>So using functions (actually like <code>pi()</code> in <code>:math</code>) or even putting it as a config is exactly solving these two use cases.</p>
<p>IMHO, putting all the constants in one place like we do in Elixir apps within the config is the way to do it or within a module (I like to have <code>MyApp</code> full of my constants and magic numbers or submodule if I want to namespace them). This is my argument about being all good in Elixir.</p>
<p>Of course we can still use for one-file uses cases the module attributes (like we for fields in Schemas or like in test files with attributes, etc.).</p>
<p>But I can see the following addition (to the formatter at least), maybe we can add a module attribute to tell that the following function is intended to be a constant and then allowing for that function to be used without parentheses (and maybe bring some optimization as well regarding memory mapping).</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Math do

  @constant #or whatever keyword
  def pi, do: 3.141592653589793
end

MyMath.pi # vs Math.pi() enforced by the formatter

# Some people don't like not having them all uppercase..
# But even if we allow to use uppercase only in this situation,
# Math.PI will definitely be confusing as a module in Elixirland
# Math.pi might also recall as a map field, which is semantically equivalent here, so win-win
</code></pre>
<p>Anyway, sorry for this long message and hope it makes sense..</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326997" 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/blog-post-10-elixir-gotchas/63278/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-326997" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326997"
                     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="327011" data-post-id="327011">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="altdsoy" data-post="22" data-topic="63278">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/altdsoy/48/25071_2.png" class="avatar"> altdsoy:</div>
<blockquote>
<p>Is this also applicable to values we are setting in the <code>config.exs</code></p>
</blockquote>
</aside>
<p>The values you set in config.exs &amp; co are stored in an ETS table, and so they are copied over to the caller process on each fetch. So in this case you might end up with many copies of a large list (e.g. if it is fetched by each request handler process).</p>
<p>Even without this issue, I personally find exs scripts confusing, and I advise avoiding them as much as possible. Can’t be done always, but they can be significantly shrunk.</p>
<p>When it comes to constants, i.e. giving a meaningful name to a magical value, my advice is to use local variable (if it is needed only in one function), or a named function placed in the module which is responsible for the related part of the functionality (i.e. not stashing all into one single module with constants).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="327011" data-batch-url="/posts/batch_likers">
                        4
                      </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/blog-post-10-elixir-gotchas/63278/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-327011" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327011"
                     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="327022" data-post-id="327022">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sasajuric" data-post="23" data-topic="63278">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/48/991_2.png" class="avatar"> sasajuric:</div>
<blockquote>
<p>Even without this issue, I personally find exs scripts confusing, and I advise avoiding them as much as possible. Can’t be done always, but they can be significantly shrunk.</p>
</blockquote>
</aside>
<p>Can you expand on that please? How? Can the config scripts be <code>.ex</code> and not <code>.exs</code>?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="327022" 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/blog-post-10-elixir-gotchas/63278/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-327022" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327022"
                     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="327036" data-post-id="327036">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>For all the concern about mutability of module attributes during compilation, consider that is the mechanism that lets ExUnit <span class="mention">@tag</span> s work. So, there’s an advantage too.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="327036" 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/blog-post-10-elixir-gotchas/63278/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-327036" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327036"
                     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="327057" data-post-id="327057">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Something to help with constants in Elixir:</p>
<aside class="quote quote-modified" data-post="1" data-topic="63308">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/48/18942_2.png" class="avatar">
    <div class="quote-title__text-content">
      <a href="https://forum.elixirforum.com/t/defconstant-library-for-defining-constants-in-your-module/63308" rel="nofollow">defconstant - library for defining constants in your module</a> <a class="badge-category__wrapper " href="/c/news/announcing/159" rel="nofollow"><span data-category-id="159" style="--category-badge-color: #d2407f; --category-badge-text-color: #FFFFFF; --parent-category-badge-color: #d2407f;" data-parent-category-id="158" data-drop-close="true" class="badge-category --style-square --has-parent"><span class="badge-category__name">Announcing</span></span></a>
    </div>
  </div>
  <blockquote>
    It is partially a response to <a class="mention" href="/u/pragtob" rel="nofollow">@PragTob</a>’s blogpost 
<a href="https://forum.elixirforum.com/t/blog-post-10-elixir-gotchas/63278" class="onebox" target="_blank" rel="noopener nofollow">https://forum.elixirforum.com/t/blog-post-10-elixir-gotchas/63278?u=hauleth</a> 
and <a class="mention" href="/u/michalmuskala" rel="nofollow">@michalmuskala</a>’s <a href="https://twitter.com/michalmuskala/status/1785313458470191559" rel="noopener nofollow ugc">tweet</a>: 

We need proper first-class constants in Erlang that a module can define 

It simply allows you to quickly define constants in your modules without resolving to “ugly hacks” in form of module attributes or unquote in “weird places”. 
Source: 
<a href="https://github.com/hauleth/defconst" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/hauleth/defconst</a> 
Hex: 
<a href="https://hex.pm/packages/defconstant" class="onebox" target="_blank" rel="noopener nofollow">https://hex.pm/packages/defconstant</a> 

Usage is dumb simpl…
  </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="327057" data-batch-url="/posts/batch_likers">
                        4
                      </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/blog-post-10-elixir-gotchas/63278/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-327057" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327057"
                     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="327095" data-post-id="327095">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="PragTob" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/PragTob/120/2401_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  PragTob
                    <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>The point of the gotcha isn’t “module attributes bad” but “module attributes as a workaround for constants have some issues”. Much like a lot of the gotchas, the behavior is usually there for a reason - but that doesn’t mean it isn’t confusing.</p>
<p>I personally don’t understand in what scenario I’d like to have the “Erlang Term Ordering” behaviour though. Instead of comparing 2 values of different types returning a “random” (–&gt; somewhat arbitrary order) boolean value I think I’d much prefer an exception, as I don’t see when you’d want that behavior. I’m sure I’m missing something, as it was designed by good people.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="327095" 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/blog-post-10-elixir-gotchas/63278/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-327095" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327095"
                     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="327102" data-post-id="327102">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Off the top of my head, if we have a number of function heads that match different types of values, there may be a compiler optimization for efficient branching/jumps when recursing through long lists or other data structures like map keys?</p> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I didn’t want to dive into a constant convo as I am prone to soapboxing buuuuuut I really like how “constants” work in Elixir, or rather the lack of them.  It always drove me nuts when there would be a massive mess of constants at the top of a file.  I also feel “public constants” are an anti-pattern so it’s great we don’t even have the choice.  To me that is a function as stated in your article, <a class="mention" href="/u/pragtob" rel="nofollow">@PragTob</a>.  Otherwise, I use config as <a class="mention" href="/u/altdsoy" rel="nofollow">@altdsoy</a> mentioned as a lot of the time that’s what it is.  I disagree with that tweet asking for attribute accessors—again, that is just a function.  I’ve seen this in Elixir and don’t see the value:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">@not_quite_pi 3.14
def not_quite_pi, do: @not_quite_pi
</code></pre>
<p>Perhaps I’m missing something, but I also saw this in Ruby and didn’t get it there either.  Feels like cargo culting to me.</p>
<p>Regarding the mutability, as <a class="mention" href="/u/gregvaughn" rel="nofollow">@gregvaughn</a> says: it’s <em>compile time</em> mutability, so unless you have 100s of them and can’t see the forest for the trees, there’s pretty much no chance you’re going to accidentally redefine one.  Otherwise, they don’t even exist at runtime (well, I know there is a way to make them stick around but it’s not ergonomic for business logic).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="327103" 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/blog-post-10-elixir-gotchas/63278/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-327103" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327103"
                     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="327107" data-post-id="327107">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="PragTob" data-post="27" data-topic="63278">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/pragtob/48/2401_2.png" class="avatar"> PragTob:</div>
<blockquote>
<p>I personally don’t understand in what scenario I’d like to have the “Erlang Term Ordering” behaviour though.</p>
</blockquote>
</aside>
<p>The term ordering is essential for data structures such as maps, sets, ordsets, orddict, and others. Dynamic languages have heterogeneous collections, which means you can have keys, lists, and sets with distinct data types. Some of these data structures are more efficiently implemented by having a total order. If Erlang/Elixir only allowed you to compare the same data types, those data structures would have to define their “total” ordering, and it would ultimately be inefficient, especially for composite data types (e.g. storing structs inside sets, such as a set of dates).</p>
<p>The main source of confusion is because Elixir comparison operators are structural, not semantic. But there are good reasons for those as well. The docs go in detail over this: <a href="https://hexdocs.pm/elixir/main/Kernel.html#module-structural-comparison" class="inline-onebox" rel="nofollow">Kernel — Elixir v1.21.0-dev</a></p>
<aside class="quote no-group" data-username="gregvaughn" data-post="25" data-topic="63278">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>For all the concern about mutability of module attributes during compilation</p>
</blockquote>
</aside>
<p>The mutability of module attributes shouldn’t be a concern, really. Defining modules in Elixir is <em>mutable a whole</em>. <code>defmodule</code>, <code>def</code>, attrs are all mutable operations that define a module, functions, etc as you execute them. This what allows you, for example, to programmatically define a function. But, as meta-programming, those abilities are only really there at compile-time by design.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="327107" data-batch-url="/posts/batch_likers">
                        6
                      </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/blog-post-10-elixir-gotchas/63278/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-327107" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327107"
                     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 #29"></div>
  </section>
</div>
    <div class="postbit" id="327111" data-post-id="327111">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="PragTob" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/PragTob/120/2401_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  PragTob
                    <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 group-livebook_core_team quote-modified" data-username="josevalim" data-post="30" data-topic="63278">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/48/1787_2.png" class="avatar"> josevalim:</div>
<blockquote>
<p>The main source of confusion is because Elixir comparison operators are structural, not semantic. But there are good reasons for those as well. The docs go in detail over this: <a href="https://hexdocs.pm/elixir/main/Kernel.html#module-structural-comparison" rel="noopener nofollow ugc">Kernel — Elixir v1.17.0-dev</a></p>
</blockquote>
</aside>
<p>Thanks a lot as always <a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> <img src="https://forum.elixirforum.com/images/emoji/apple/green_heart.png?v=15" title=":green_heart:" class="emoji" alt=":green_heart:" loading="lazy" width="20" height="20"> That makes sense, I’ll link it in the blog post and of course it’s already documented… maybe I should go and read the entire docs again at some point for all the great stuff that has been added!</p>
<aside class="quote no-group" data-username="sodapopcan" data-post="29" data-topic="63278">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/48/34668_2.png" class="avatar"> sodapopcan:</div>
<blockquote>
<p>I disagree with that tweet asking for attribute accessors—again, that is just a function. I’ve seen this in Elixir and don’t see the value:</p>
</blockquote>
</aside>
<p>I mean - there are other ways to do it but I think sharing some data/defaults isn’t too bad. Like - the default country, default payment method, the maximum age, maximum/minimum transaction amounts. Of course, better if you manage to contain them in one module - but it can be hard.<br>
I mean, you can make an argument that all of these could instead be in a config - but the config are also constant-like (plus difference for different environment, which often means a lot).</p>
<p>That said, I agree that constants in Ruby being “public” by default I don’t like. In that sense, needing to “wrap” a module attribute in a function to make it accessible can be a boon imo <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> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="327111" 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/blog-post-10-elixir-gotchas/63278/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-327111" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="327111"
                     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 #30"></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/63278/load_more?page=4">Load more posts (14 remaining)</a>
</div></template></turbo-stream>