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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So when building a DSL, I often (following Ecto’s examples) will have an <code>__attribute__/1</code> and similar functions that my DSL eventually calls into. Elixir does not generate documentation about these functions I’m wondering if there’s some parallel that can be made here, perhaps naming the modules <code>defmodule __MyPrivateModule__ do ... end</code> to convey similar intent. I’m not sure if we’re past that point already, but if it’s really just signalling to a user that something is private, that’s ugly enough to give a user pause, I think, and aligns with other conventions in the language, without requiring a new language concept, or requiring the private module to know its callers.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="111419" 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/proposal-private-modules-general-discussion/19374/72">Post #71</a>
	                </div>
	            </div>
              <div id="likers-container-111419" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111419"
                     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 #71"></div>
  </section>
</div>
    <div class="postbit" id="111421" data-post-id="111421">
  <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">
								<p>That’s a good question <a class="mention" href="/u/asummers" rel="nofollow">@asummers</a>. Unfortunately <code>__MyPrivateModule__ </code> is not a valid alias name. Anything that starts with an underscore is either a function name or a variable. We could change the language to make <code>__MyPrivateModule__</code> actually be an alias by checking the first letter after the underscores but that would not work with existing variables such as <code>__MODULE__</code> and <code>__ENV__</code>. We would need to at least special case them in the parser (which is fine, they are already special cased in the compiler anyway).</p>
<p>The only downside of this approach is that it doesn’t say to which modules an underscored module would be visible to.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="111421" 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/proposal-private-modules-general-discussion/19374/73">Post #72</a>
	                </div>
	            </div>
              <div id="likers-container-111421" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111421"
                     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 #72"></div>
  </section>
</div>
    <div class="postbit" id="111422" data-post-id="111422">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>The only downside of this approach is that it doesn’t say to which modules an underscored module would be visible to.</p>
</blockquote>
<p><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> I think that’s okay personally. I don’t think this is something the compiler should need to enforce if the problem is largely social. If someone’s using an underscored module, that’s their fault. They know the risks when they decided to use that module name, same as if they called an underscored function name. Perhaps that isn’t strong enough but to me not closing the private module (a la open/closed type semantics) seems more optimal.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="111422" 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/proposal-private-modules-general-discussion/19374/74">Post #73</a>
	                </div>
	            </div>
              <div id="likers-container-111422" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111422"
                     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 #73"></div>
  </section>
</div>
    <div class="postbit" id="111424" data-post-id="111424">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I rather like having to use <code>requirep</code> insead od <code>require</code> + <code>alias</code>. It makes it explicit that we’re requiring a private module.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="111424" 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/proposal-private-modules-general-discussion/19374/75">Post #74</a>
	                </div>
	            </div>
              <div id="likers-container-111424" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111424"
                     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 #74"></div>
  </section>
</div>
    <div class="postbit" id="111425" data-post-id="111425">
  <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 quote-modified" data-username="OvermindDL1" data-post="71" data-topic="19374">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Maybe the tuple should even encode the <code>SomeDep</code> 's version number somehow as well, so it must be changed (or removed and properly fixed) each time it is updated.</p>
</blockquote>
</aside>
<p>In such case I would prefer to require using <code>==</code> when defining dependency version.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyApp.Mixfile do
  # …

  def project do
    [
      # …
      deps: [{:some_dep, "== 1.5.3"}], # fails if not using == version check
      private_access_overrides: [ # By this not being empty then this project is not allowed onto hex.pm
        some_dep: {SomeDep.Private, [MyApp.Some.Specific.Module, MyApp.Some.Other.Specific.Module]}
      ],
      # …
    ]
  end

  # …
end
</code></pre>
<p>I like that idea, but note that in such case we would also need option like: <code>package_namespaces: [MyApp, MyAppTest]</code> and validate all defined modules inside <code>lib</code> and <code>test</code>. It’s because somebody could write <code>defmodule SomeDep.Hack do … end</code>. The problem with that is we can’t do it directly in compiler as <a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> said. Doing it from some code analyse tools is also not a solution, because we could call something like: <code>Code.require_file("hacks/some_dep/hack.ex")</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="111425" 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/proposal-private-modules-general-discussion/19374/76">Post #75</a>
	                </div>
	            </div>
              <div id="likers-container-111425" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111425"
                     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 #75"></div>
  </section>
</div>
    <div class="postbit" id="111427" data-post-id="111427">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </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="76" data-topic="19374">
<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>In such case I would prefer to require using <code>==</code> when defining dependency version.</p>
</blockquote>
</aside>
<p>The dependency resolver could use the information from the private access listing to try to acquire that specific version as well, but honestly I’d still prefer it to ignore it and for updates to ‘break’ it to encourage fixing it faster.  It’s not like such a library that uses this construct would be allowed on hex.pm anyway.</p>
<p>Hmm, actually another idea, the private access overrides could go as options on the dependency tuple itself…  Many places it could go.</p>
<aside class="quote no-group quote-modified" data-username="Eiji" data-post="76" data-topic="19374">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>It’s because somebody could write <code>defmodule NotMyLibrary.Hack do … end</code> .</p>
</blockquote>
</aside>
<p>And can’t forget that that could be entirely intentional, like say to expose a ‘private’ API only to a protocol’s implementations.</p>
<aside class="quote no-group" data-username="Eiji" data-post="76" data-topic="19374">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>but note that in such case we would also need option like: <code>package_namespaces: [MyApp, MyAppTest]</code></p>
</blockquote>
</aside>
<p>I’m not sure what an option would be for?</p>
<p>Though I don’t think the original C option to allow it to be an entire subtree match is right either, that should also be explicitly per-specific-module with an option for an entire subtree (great for protocols for example).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="111427" 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/proposal-private-modules-general-discussion/19374/77">Post #76</a>
	                </div>
	            </div>
              <div id="likers-container-111427" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111427"
                     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 #76"></div>
  </section>
</div>
    <div class="postbit" id="111429" data-post-id="111429">
  <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="OvermindDL1" data-post="77" data-topic="19374">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>I’m not sure what an option would be for?</p>
</blockquote>
</aside>
<p>Ah, sorry - I though that you are talking about extra protection (when reading that part with <code>hex</code> checks), so I just started talking about possible hacks. <img src="https://forum.elixirforum.com/uploads/default/original/2X/2/20c9c52366de24191270f0b11311379ce60ac82d.gif?v=15" title=":077:" class="emoji emoji-custom" alt=":077:" loading="lazy" width="20" height="20"></p>
<p>I did not realized that you wanted to only <strong>extend</strong> access for specific private modules. It’s good idea too. <img src="https://forum.elixirforum.com/images/emoji/apple/+1.png?v=15" title=":+1:" class="emoji" alt=":+1:" 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="111429" 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/proposal-private-modules-general-discussion/19374/78">Post #77</a>
	                </div>
	            </div>
              <div id="likers-container-111429" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111429"
                     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 #77"></div>
  </section>
</div>
    <div class="postbit" id="111430" data-post-id="111430">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Option C gets my vote. I also quite like the <code>defmodulep</code> naming.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="111430" data-batch-url="/posts/batch_likers">
                        5
                      </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/proposal-private-modules-general-discussion/19374/79">Post #78</a>
	                </div>
	            </div>
              <div id="likers-container-111430" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111430"
                     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 #78"></div>
  </section>
</div>
    <div class="postbit" id="111431" data-post-id="111431">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It would be nice if <code>requirep Foo.Bar</code> could automatically alias <code>:"Elixirp.Foo.Bar"</code> to <code>Foo.Bar</code> (I’m aware that elixir doesn’t support nested aliases and it probably won’t happen).<br>
Anyway, option <strong>C</strong> is something that would be useful for me even 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="111431" 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/proposal-private-modules-general-discussion/19374/80">Post #79</a>
	                </div>
	            </div>
              <div id="likers-container-111431" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111431"
                     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 #79"></div>
  </section>
</div>
    <div class="postbit" id="111432" data-post-id="111432">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I also like the name mangling features. I suggest a deterministic naming scheme like the following: <code>Elixirp.&lt;hash_of_the_module_name&gt;.Module.Name</code>. That</p>
<p>I wonder if it would be possible to have a <code>make_all_private_modules_public/0</code> function or macro on IEx, which would alias all private modules somehow.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="111432" 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/proposal-private-modules-general-discussion/19374/81">Post #80</a>
	                </div>
	            </div>
              <div id="likers-container-111432" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="111432"
                     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 #80"></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/19374/load_more?page=9">Load more posts (77 remaining)</a>
</div></template></turbo-stream>