<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="139383" data-post-id="139383">
  <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="timCF" data-post="11" data-topic="24528">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/timcf/48/3620_2.png" class="avatar"> timCF:</div>
<blockquote>
<p>But these code examples are not the same things. Your example is less performant because there is call of access protocol in runtime. And it’s also less safe because something like <code>calsulus(state: state, returnnnnn: return)</code> will survive compilation. And the worst thing will happen in runtime - access protocol will return implicit <code>nil</code> for this value, and consequences of this are unpredictable, depends on other code - sometimes it can behave correct, sometimes can behave incorrect, sometimes can raise exceptions.</p>
</blockquote>
</aside>
<p>Right, as you said it’s just code example - not <code>prod</code> version. You can simply use <code>&amp;Keyword.fetch!/2</code> instead. Also it’s easy for just 2 arguments - if you take look at my proposition with 4 arguments you will end up with way too much code.</p>
<aside class="quote no-group" data-username="timCF" data-post="11" data-topic="24528">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/timcf/48/3620_2.png" class="avatar"> timCF:</div>
<blockquote>
<p>About other your suggestions about syntax sugar - it’s really sugar, question of preferences in design. Maybe it make sense for someone, maybe not, I don’t know. I thought about DSL with <code>type</code> , <code>private</code> , <code>public</code> , <code>immutable</code> and <code>method</code> keywords - to avoid boilerplate and auto-generate at least getters, maybe some setters. But finally just decided to make interface as much simple and explicit as possible, with smallest possible amount of abstractions. If I, or someone else needs more high-level DSL - he can build it on top of my library pretty easy, because interface is straightforward.</p>
</blockquote>
</aside>
<p>Simple for you does not needs to mean simple for others and for sure same goes to my old code. For example your <code>defcalculus</code> macro takes more than 100 lines - that’s way too much (take a look at <code>credo</code> library). I’m not someone pro who decides what things are good or bad practices. I simply take a look at other libraries. When I’m writing code I think if I will understand it even after <code>x</code> years. Can you quickly say what this code is doing?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">case left do
  [{:when, ctx0, [e | es]}] -&gt; [{:when, ctx0, [e, key | es]}]
  [e] -&gt; [e, key]
end
</code></pre>
<p>For sure it’s really easy example and most probably you would know it. Now here goes beginner and see: <code>e</code> and <code>es</code> which says exactly <strong>nothing</strong>. It’s just code style, sugar, but in matter especially when you are working in team.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmacrop construct(state) do
  quote location: :keep do
    fn :new, @security_key -&gt;
      calculus(state: unquote(state), return: :ok)
    end
    |&gt; eval(:new)
  end
end
</code></pre>
<p>If I understand correctly this macro could be simply imported and there is no need to add it inside other macro. For sure one small macro in bigger macro is not a problem, but it’s not the only one you have in it. Even splitting it into few helper functions would make it much more readable.</p>
<p>Simply look at end of file:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">        end
      end
    end
  end
end
</code></pre>
<p>it explains everything. <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"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="139383" 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/calculus-new-data-types-private-immutable-fields-and-smart-constructors/24528/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-139383" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="139383"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="139397" data-post-id="139397">
  <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">
								<aside class="quote no-group" data-username="Eiji" data-post="4" data-topic="24528">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/48/36743_2.png" class="avatar"> Eiji:</div>
<blockquote>
<p>I really do not recommend this as BEAM have limit of atoms ( <code>1_048_576</code> by default)</p>
</blockquote>
</aside>
<p>This isn’t only problem. AFAIK functions aren’t GCed either, so it can blow up anyway as this extensively use Church structures.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="139397" 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/calculus-new-data-types-private-immutable-fields-and-smart-constructors/24528/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-139397" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="139397"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="139402" data-post-id="139402">
  <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="hauleth" data-post="13" data-topic="24528">
<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"> hauleth:</div>
<blockquote>
<p>This isn’t only problem. AFAIK functions aren’t GCed either, so it can blow up anyway as this extensively use Church structures.</p>
</blockquote>
</aside>
<p>Functions are statically compiled, they are “GC”'d when the module is replaced or removed.  A Closure on the beam is just a function pointer, like <code>&amp;Blah.bloop/2</code> and an environment mapping (positional internally).  There are no GC issues there.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="139402" 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/calculus-new-data-types-private-immutable-fields-and-smart-constructors/24528/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-139402" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="139402"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Qqwy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Qqwy/120/1349_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Qqwy
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>TypeCheck Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This is very interesting! <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="139935" 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/calculus-new-data-types-private-immutable-fields-and-smart-constructors/24528/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-139935" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="139935"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="timCF" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/timCF/120/3620_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  timCF
                    <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>Here you can find one more example of usage, abstract Maybe type which implements Functor, Applicative and Monad behaviours</p>
<p><a href="https://github.com/timCF/category" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/timCF/category</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="140632" 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/calculus-new-data-types-private-immutable-fields-and-smart-constructors/24528/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-140632" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="140632"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="140644" data-post-id="140644">
  <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="timCF" data-post="16" data-topic="24528">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/timcf/48/3620_2.png" class="avatar"> timCF:</div>
<blockquote>
<p>timCF/category</p>
</blockquote>
</aside>
<p>Lol, nice building on 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="140644" 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/calculus-new-data-types-private-immutable-fields-and-smart-constructors/24528/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-140644" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="140644"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

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