<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="185740" data-post-id="185740">
  <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
                    <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>Replying to <a class="mention" href="/u/rvirding" rel="nofollow">@rvirding</a> here since it’s related to his explanation that has now really sunk in, but open to anyone.</p>
<p>So as I understand it, the only difference between <code>handle_cast</code> and <code>handle_info</code> is that the former is used by clients who know the API of the server in question whereas the latter is used by clients who have no idea who they are sending messages to.  Is the sole advantage here having a clean API for clients who know who they are dealing with, or could one theoretically just always use <code>handle_info</code> with <code>send(pid, message)</code>?</p>
<p>One scenario that has just occurred to me as I typed this is when communicating with servers through a module which hides the <code>pid</code>.  That alone makes <code>handle_cast</code> necessary.  Uhhh, I may have just answered my own question, but is there anything else I’m not thinking of??</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="185740" 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/what-is-the-etymology-of-genserver-cast/33610/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-185740" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="185740"
                     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="185761" data-post-id="185761">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>No, sorry that’s wrong, well only partially right.</p>
<p><code>gen_server:cast</code> and its callback <code>handle_cast</code> is used when sending an asynchronous request to a genserver in which there is no reply expected a or sent back to caller. It is just a “do this but don’t tell me about it”. The <code>handle_cast</code> is expected to return a <code>{noreply, State}</code>. Note that doing a <code>gen_server:cast</code> to a server causes the server to the <code>handle_cast</code> callback as they are coupled together.</p>
<p>The <code>handle_info</code> callback is called when an <strong>unrecognised</strong> message is received by the server. The server, while it may be a gen_server, is just a normal Erlang process so it can receive messages which haven’t been sent by the system or using <code>gen_server:call/cast</code>. For example it could be monitoring processes or nodes, or be linked to processes and trapping exits so it receive exit messages. The top-level server loop handles <strong>all</strong> messages and anything it doesn’t recognise results in it calling <code>handle_info</code>. This allows the users behaviour module to handle everything.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="185761" 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/what-is-the-etymology-of-genserver-cast/33610/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-185761" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="185761"
                     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="185774" data-post-id="185774">
  <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
                    <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>Hey, that’s cool, I don’t mind being wrong! <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>
<p>Thanks for the <em>info</em> (har har, get it?).  My thinking was just a little off in terms of what is considered “unrecognized” but this makes sense (I was thinking exits and whatnot could be considered “recognized”).  Thanks again!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="185774" 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/what-is-the-etymology-of-genserver-cast/33610/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-185774" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="185774"
                     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="186050" data-post-id="186050">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>As both an Elixir developer and language nerd I can’t resist this.</p>
<p>For me, <code>handle_cast</code> always brought to mind <em>broadcast</em>.  The <em>throw without expecting anything back</em> meaning makes sense too. (I guess calling it <em>throw</em> would be confusing because that is used in a lot of languages for exceptions.)</p>
<p>From the Oxford, that sense of <em>cast</em> is this one:</p>
<p>1 <em>[usually with adverbial of direction]</em> <em>mainly literary</em> <strong>throw (something) forcefully in a specified direction</strong>: <em>he cast the book down on to the chair angrily</em> | <em>the fishermen cast a large net around a school of tuna</em> | figurative :  <em>individuals who do not accept the norms are <em><strong>cast out</strong></em> from the group</em>.</p>
<p>For typecasting, I always had the idea of moulding something into the shape that you want; that’s this sense (especially the third one):</p>
<p>4 <strong>shape (metal or other material) by pouring it into a mould while molten</strong>: <em>when hammered or cast, bronze could be made into tools</em>.<br>
• <strong>make (a moulded object) by casting metal</strong>: <em>a bell was cast for the church</em>.<br>
• <strong>arrange and present in a specified form or style</strong>: <em>he issued statements cast in tones of reason</em>.</p>
<p>Etymology:</p>
<p>Middle English: from Old Norse <em><strong>kasta</strong></em> ‘to cast or throw’.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="186050" 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/what-is-the-etymology-of-genserver-cast/33610/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-186050" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="186050"
                     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>