<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="309975" data-post-id="309975">
  <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
                    <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 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="hubertlepicki" data-post="32" data-topic="60130" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hubertlepicki/48/6822_2.png" class="avatar"> hubertlepicki:</div>
<blockquote>
<p>The difference being that we currently do it with function calls, and not dedicated operators (@@)</p>
</blockquote>
</aside>
<p>Correct, but it requires actual mutable state, has worse performance, and has a less friendly user experience as the compiler cannot tell you when you are accessing something that could have been “dealocated”. So the question is: solving this problem in a faster, immutable, and with better dx worth the syntax additions?</p>
<aside class="quote no-group" data-username="adw632" data-post="25" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>Would this be valid?</p>
<p><code>def some_func(%{foo: @@bar}) when @@bar &lt; 5</code></p>
</blockquote>
</aside>
<p>Yes. They can be used anywhere a variable would be used.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309975" data-batch-url="/posts/batch_likers">
                        7
                      </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/local-accumulators-for-cleaner-comprehensions/60130/33">Post #32</a>
	                </div>
	            </div>
              <div id="likers-container-309975" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309975"
                     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 #32"></div>
  </section>
</div>
    <div class="postbit" id="309979" data-post-id="309979">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The is no mutability in the proposal. It is “just” enabling rebinding within the scope the variable is declared and all inner scopes.</p>
<p>We can already rebind variables within a scope, we can’t rebind them from inner scopes. The proposal is essentially relaxing this restriction and using a designated prefix to distinguish them and to <em>avoid</em> some unintended shadowing use cases.</p>
<p>I say <em>avoid</em> because if these do catch on then there still will be accidental shadowing. You may intend to introduce a new <code>@@foo</code>  one scope down and you end up shadowing a previous but different <code>@@foo</code> in the same function.</p>
<p>The most insideous case would be a module level <code>@@foo</code> in another ModuleB that gets imported into the current ModuleA. Does that ModuleB <code>@@foo</code> get imported too?</p>
<p>If yes, and I have also have a ModuleA level <code>@@foo</code>, which <code>@@foo</code> would be used? Perhaps a compiler error leading to fragile code evolution?</p>
<p>What if I am implementing a callback for a behaviour?</p>
<p>Does the <code>@@foo</code> in my function use ModuleB’s <code>@@foo</code> if I haven’t declared a <code>@@foo</code>  in ModuleA?</p>
<p>Or if we do declare a ModuleA scope <code>@@foo</code> do we have two instances of <code>@@foo</code>,  where functions in ModuleA use that modules <code>@@foo</code> and the functions in ModuleB use the <code>@@foo</code> in ModuleB and  now we have inconsistency between the <code>@@foo</code> used in functions we inherit from ModuleB but don’t override and those functions we implement?</p>
<p>This kind of cross module gymnastics with module scoped <code>@@foo</code> almost reminds me of multiple inheritance hell in C++</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309979" 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/local-accumulators-for-cleaner-comprehensions/60130/34">Post #33</a>
	                </div>
	            </div>
              <div id="likers-container-309979" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309979"
                     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 #33"></div>
  </section>
</div>
    <div class="postbit" id="309981" data-post-id="309981">
  <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
                    <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 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="adw632" data-post="34" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>The most insideous case would be a module level <code>@@foo</code> in another ModuleB that gets imported into the current ModuleA. Does that ModuleB <code>@@foo</code> get imported too?</p>
</blockquote>
</aside>
<p>You wouldn’t be able to import or access a variable or local accumulator from ModuleB, unless it is via a macro. The problems you are describing would not really happen. And in the macro case, we already have variable hygiene.</p>
<p>Just ask yourself: can I access a variable defined in moduleB from moduleA? If the answer is no, then you cannot access a local accumulator either.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309981" 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/local-accumulators-for-cleaner-comprehensions/60130/35">Post #34</a>
	                </div>
	            </div>
              <div id="likers-container-309981" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309981"
                     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 #34"></div>
  </section>
</div>
    <div class="postbit" id="309983" data-post-id="309983">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adw632" data-post="34" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>The is no mutability in the proposal. It is “just” enabling rebinding within the scope the variable is declared and all inner scopes.</p>
<p>We can already rebind variables within a scope, we can’t rebind them from inner scopes. The proposal is essentially relaxing this restriction and using a designated prefix to distinguish them and to <em>avoid</em> some unintended shadowing use cases.</p>
</blockquote>
</aside>
<p>I’m aware <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"> That’s why I prefixed it with “(not really)”.</p>
<aside class="quote no-group quote-modified" data-username="adw632" data-post="34" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>The most insideous case would be a module level <code>@@foo</code> in another ModuleB that gets imported into the current ModuleA. Does that ModuleB <code>@@foo</code> get imported too?</p>
<p>If yes, and I have also have a ModuleA level <code>@@foo</code>, which <code>@@foo</code> would be used? Perhaps a compiler error leading to fragile code evolution?</p>
<p>What if I am implementing a callback for a behaviour?</p>
<p>Does the <code>@@foo</code> in my function use ModuleB’s <code>@@foo</code> if I haven’t declared a <code>@@foo</code> ?</p>
<p>Or if we do declare a ModuleB scope <code>@@foo</code> do we have two instances of <code>@@foo</code>, where functions in ModuleA use that modules <code>@@foo</code> and the functions in ModuleB use the <code>@@foo</code> in ModuleB and now we have inconsistency between the <code>@@foo</code> used in functions we inherit from ModuleB but don’t override and those functions we implement?</p>
<p>This kind of cross module gymnastics with module scoped <code>@@foo</code> almost reminds me of multiple inheritance hell in C++</p>
</blockquote>
</aside>
<p>I’m not sure I follow what you mean by “importing <code>@@foo</code>”. If you mean by using the <code>import</code> feature, I don’t think it would be possible (just like we can’t import regular variables defined at the module level).</p>
<p>If you’re talking about meta-programming, macro hygiene should have us covered. Take the following code:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule ModA do
  defmacro __using__(_) do
    quote do
      my_var = 1
    end
  end
end

defmodule ModB do
  use ModA

  IO.inspect(my_var)
end
</code></pre>
<p>This gives a compilation error since from <code>ModB</code> perspective, <code>my_var</code> doesn’t exist. My understanding is that the same would be true with the <code>@@</code> variables.</p>
<p>Similarly, you can’t mutate a module-level variable from a function not because they are in different scopes, but because they are in completely different execution environments. For instance:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  my_var = 1

  def my_func do
    my_var
  end
end
</code></pre>
<p>This gives a compile error as well. You’d need to interpolate the variable using <code>unquote</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  my_var = 1

  def my_func do
    unquote(my_var)
  end
end

MyMod.my_func() # =&gt; 1
</code></pre>
<p>Again I believe this would be the same behavior with the <code>@@</code> variables.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309983" 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/local-accumulators-for-cleaner-comprehensions/60130/36">Post #35</a>
	                </div>
	            </div>
              <div id="likers-container-309983" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309983"
                     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 #35"></div>
  </section>
</div>
    <div class="postbit" id="309985" data-post-id="309985">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for that.</p>
<p>However we would have functions in ModuleB using that modules <code>@@foo</code> and any functions we override would not have access unless provided through some ModuleB function just like a normal module attribute.</p>
<p>In respect of a module level <code>@@foo</code> and regular module attribute <code>@foo</code>, what is the material difference? Is it just the assignment syntax?</p>
<p>Given you can’t rebind to a module level <code>@@foo</code> at runtime I assume this would generate a compiler error or would you allow a function or inner scope to shadow a module variable?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309985" 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/local-accumulators-for-cleaner-comprehensions/60130/37">Post #36</a>
	                </div>
	            </div>
              <div id="likers-container-309985" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309985"
                     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 #36"></div>
  </section>
</div>
    <div class="postbit" id="309988" data-post-id="309988">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adw632" data-post="37" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>In respect of a module level <code>@@foo</code> and regular module attribute <code>@foo</code>, what is the material difference? Is it just the assignment syntax?</p>
</blockquote>
</aside>
<p>If I understood correctly, <code>@@foo</code> would behave more like a normal variable <code>foo</code> than like a  module attribute <code>@foo</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  @foo :a
  foo = :b
  @@foo = :c

  def my_func do
    # you need to unquote `foo` and `@@foo` to access their value here
    {@foo, unquote(foo), unquote(@@foo)}
  end
end
</code></pre>
<p>I think the value of something like <code>@@foo</code> at the module level would be fairly limited, as we rarely use nested scopes in the module level (like <code>if</code>/<code>for</code>/<code>case</code>), unless you’re doing metaprogramming, in which case it could be useful:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  @@counter = 0

  for name &lt;- [:foo, :bar, :baz] do
    @@counter = @@counter + 1

    def unquote(name)(), do: unquote(@@counter)
  end
end

MyMod.foo() # =&gt; 1
MyMod.bar() # =&gt; 2
MyMod.baz() # =&gt; 3
</code></pre>
<p>Although the above is already possible today by redefining module attributes:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  @counter 0

  for name &lt;- [:foo, :bar, :baz] do
    @counter @counter + 1

    def unquote(name)(), do: @counter
  end
end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309988" data-batch-url="/posts/batch_likers">
                        3
                      </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/local-accumulators-for-cleaner-comprehensions/60130/38">Post #37</a>
	                </div>
	            </div>
              <div id="likers-container-309988" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309988"
                     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 #37"></div>
  </section>
</div>
    <div class="postbit" id="309989" data-post-id="309989">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>And what about this?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  @@counter = 0

  def alpha(), do: @@counter

  for name &lt;- [:foo, :bar, :baz] do
    @@counter = @@counter + 1

    def unquote(name)(), do: unquote(@@counter)
  end
  
  def omega(), do: @@counter
end

MyMod.alpha() # =&gt; 0 ??
MyMod.foo() # =&gt; 1
MyMod.bar() # =&gt; 2
MyMod.baz() # =&gt; 3
MyMod.omega() # =&gt; 3  ??
</code></pre>
<p>Or does it not compile?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309989" 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/local-accumulators-for-cleaner-comprehensions/60130/39">Post #38</a>
	                </div>
	            </div>
              <div id="likers-container-309989" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309989"
                     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 #38"></div>
  </section>
</div>
    <div class="postbit" id="309990" data-post-id="309990">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It would be a compile error, yeah, you’d have to do something like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  @@counter = 0

  def alpha(), do: unquote(@@counter)

  for name &lt;- [:foo, :bar, :baz] do
    @@counter = @@counter + 1

    def unquote(name)(), do: unquote(@@counter)
  end
  
  def omega(), do: unquote(@@counter)
end
</code></pre>
<p>In which case they would take “snapshots” of the current value of <code>@@counter</code> (since <code>unquote</code> is evaluated at the module-level in these cases). So I believe that with the proposal it would work something like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">MyMod.alpha() # =&gt; 0
MyMod.foo() # =&gt; 1
MyMod.bar() # =&gt; 2
MyMod.baz() # =&gt; 3
MyMod.omega() # =&gt; 3
</code></pre>
<p>Which again is already possible today with plain module attributes:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyMod do
  @counter 0

  def alpha(), do: @counter

  for name &lt;- [:foo, :bar, :baz] do
    @counter @counter + 1

    def unquote(name)(), do: @counter
  end
  
  def omega(), do: @counter
end
</code></pre>
<p>So I don’t think this proposal would have an impact on how module-level values would leak to function-level scopes, as essentially all that would be made possible at the module-level is already possible with module attributes today.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309990" 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/local-accumulators-for-cleaner-comprehensions/60130/40">Post #39</a>
	                </div>
	            </div>
              <div id="likers-container-309990" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309990"
                     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 #39"></div>
  </section>
</div>
    <div class="postbit" id="309991" data-post-id="309991">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="vidalraphael" data-post="40" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/vidalraphael/48/32793_2.png" class="avatar"> vidalraphael:</div>
<blockquote>
<p>So I don’t think this proposal would have an impact on how module-level values would leak to function-level scopes, as essentially all that would be made possible at the module-level is already possible with module attributes today.</p>
</blockquote>
</aside>
<p>I would go as far to say they are <em>pointless</em> or even <em>harmful</em> at module scope given they only serve to create shadowing issues with function scope usage.</p>
<p>Existing module attributes do a sufficient job already and we don’t need module scope <code>@@foo</code> clashing with function scope, nor do we need to add extra typing to unquote/crystallise them when we have module level <code>@foo</code> already.</p>
<p>I would therefore suggest the proposal be paired back so that <code>@@</code> be considered only within runtime scopes and let module attributes handle the compile time usage.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309991" 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/local-accumulators-for-cleaner-comprehensions/60130/41">Post #40</a>
	                </div>
	            </div>
              <div id="likers-container-309991" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309991"
                     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 #40"></div>
  </section>
</div>
    <div class="postbit" id="309998" data-post-id="309998">
  <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
                    <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 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="adw632" data-post="41" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>I would go as far to say they are <em>pointless</em> or even <em>harmful</em> at module scope given they only serve to create shadowing issues with function scope usage.</p>
</blockquote>
</aside>
<p>Functions always start a new scope, and that would be the case here, so no shadowing because no module variable leaks in. The model is simpler than you are thinking. <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="adw632" data-post="41" data-topic="60130">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>I would therefore suggest the proposal be paired back so that <code>@@</code> be considered only within runtime scopes and let module attributes handle the compile time usage.</p>
</blockquote>
</aside>
<p>That’s typically a bad idea because Elixir doesn’t really make a distinction between runtime scope and compile time scopes. Runtime and compile-time is the same. That’s why you can use <code>if</code> or any other function/macro inside module bodies and you can also define modules inside functions. Even <code>defmodule</code> itself is just a macro and there is not much special about 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="309998" 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/local-accumulators-for-cleaner-comprehensions/60130/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-309998" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309998"
                     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 #41"></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/60130/load_more?page=5">Load more posts (205 remaining)</a>
</div></template></turbo-stream>