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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>After reading some more replies here I’m going to go sit on the fence.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="366994" data-batch-url="/posts/batch_likers">
                        9
                      </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/changes-to-the-struct-update-syntax/71232/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-366994" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="366994"
                     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="366995" data-post-id="366995">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="christhekeele" data-post="10" data-topic="71232">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/christhekeele/48/1039_2.png" class="avatar"> christhekeele:</div>
<blockquote>
<p>Then <em><strong>I would expect rules 2 and 3 to compose</strong></em>: such that structs have an update syntax <code>%module_name{var | key: val}</code>. That is, it is a syntax that emerges logically and consistently from simpler syntax rules.</p>
</blockquote>
</aside>
<p>Actually I don’t think this fully holds.</p>
<p><code>%{}</code> create new map<br>
<code>%{var | key: 10}</code> → create a new map, with all the same keys but <code>key</code> set to <code>10</code><br>
<code>%Mod{}</code> → create new Mod</p>
<p>So then we’d get to: <code>%Mod{var | key: 10}</code></p>
<p>which by the composition rules you’re describing should make a <em>new</em> <code>Mod</code> with all the keys in <code>var</code> except <code>key</code> set to <code>10</code>.</p>
<p>i.e:</p>
<p><code>%Mod{}</code> → <code>%{__struct__: Mod}</code><br>
<code>%Mod{var | key: 10}</code> → <code>%{var | __struct__: Mod, key: 10}</code></p>
<p>In typing this out, I guess its debatable if<br>
<code>%{var | __struct__: Mod, key: 10}</code><br>
would be the right interpretation, or<br>
<code>%{%{__struct__: Mod} | , key: 10}</code> in which case you’d be right?</p>
<p>Not sure <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_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="366995" 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/changes-to-the-struct-update-syntax/71232/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-366995" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="366995"
                     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="366998" data-post-id="366998">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-Ash-Core-Team" data-username="zachdaniel" data-post="16" data-topic="71232">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/48/31980_2.png" class="avatar"> zachdaniel:</div>
<blockquote>
<p>In typing this out, I guess its debatable if<br>
<code>%{var | __struct__: Mod, key: 10}</code><br>
would be the right interpretation, or<br>
<code>%{%{__struct__: Mod} | , key: 10}</code> in which case you’d be right?</p>
</blockquote>
</aside>
<p>In my mind it’s conceptually closer to the latter, but YMMV.</p>
<p>Less important, and I’m not sure I’m reading the <a href="https://github.com/elixir-lang/elixir/blob/fb9a9e97d8732e9c492c736d7aabafaa609a264e/lib/elixir/src/elixir_erl_pass.erl#L475" rel="noopener nofollow ugc">actual implementation</a> correctly, but if so it appears that</p>
<ul>
<li>struct update syntax is <a href="https://github.com/elixir-lang/elixir/blob/fb9a9e97d8732e9c492c736d7aabafaa609a264e/lib/elixir/src/elixir_erl_pass.erl#L475" rel="noopener nofollow ugc">special-cased</a> (rather than emergent)</li>
<li>to <a href="https://github.com/elixir-lang/elixir/blob/fb9a9e97d8732e9c492c736d7aabafaa609a264e/lib/elixir/src/elixir_erl_pass.erl#L475" rel="noopener nofollow ugc">model a map with the correct <code>:__struct__</code> key</a>,</li>
<li><em><strong>then</strong></em> <a href="https://github.com/elixir-lang/elixir/blob/fb9a9e97d8732e9c492c736d7aabafaa609a264e/lib/elixir/src/elixir_erl_pass.erl#L486-L487" rel="noopener nofollow ugc">apply the updates</a>.</li>
</ul>
<p>So closer to the latter than the former, but implemented specifically rather than emergent from expansion order of the two constructs.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="366998" 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/changes-to-the-struct-update-syntax/71232/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-366998" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="366998"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="367000" data-post-id="367000">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I think your point is salient FWIW. The fact that you can’t use them together might trip people up, but I do think there is still a subtle difference whereby the composition doesn’t necessarily do what it looks like it would do when combining the two. Perhaps a matter of perspective.</p>
<p><code>[a | b]</code> is an example where the same symbol has totally different properties based on its surrounding context, for however much that adds to the conversation <img src="https://forum.elixirforum.com/images/emoji/apple/laughing.png?v=15" title=":laughing:" class="emoji" alt=":laughing:" loading="lazy" width="20" height="20"> I do think that the strategy of just requiring that the value match the type if you use struct update syntax is a really elegant solution to the stated type system related issues, to the point where the <em>motivation</em> to remove the syntax seems to have been handled. If it’s coming back down to preference given that the technical issue is solved, then there is no great reason to debate the issue, and IMO no significant reason to deprecate it (and I voted on the poll as such).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367000" 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/changes-to-the-struct-update-syntax/71232/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-367000" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367000"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="367022" data-post-id="367022">
  <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="NobbZ" data-post="6" data-topic="71232">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>And unless the LSPs will provide that completion for map updates after pattern match from the first day, I don’t see me using the “new” idioms in near time…</p>
</blockquote>
</aside>
<p>So in other words some dependencies or tools like <code>LSP</code> have to be updated to support new version of the language which is completely expected I guess … This is why they announce updates sooner and give release candidates, so the community would know more about it and decide if it’s the right time to make an update. <img src="https://forum.elixirforum.com/images/emoji/apple/light_bulb.png?v=15" title=":light_bulb:" class="emoji" alt=":light_bulb:" loading="lazy" width="20" height="20"></p>
<p>In my case I’m already working on new release candidates mainly because what I commented above and because of optimisations. I see things are really going in a good direction and I’m very motivated to not stop them from making good things. <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="367022" 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/changes-to-the-struct-update-syntax/71232/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-367022" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367022"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="367023" data-post-id="367023">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I find myself in the camp that likes the explicitness of the struct update syntax.  When I see such an expression, I just don’t have a question about what the thing is and I’m clear in the communication to other readers, too.  By using the map update syntax, we weaken that more explicit expression.  That’s my simplistic take on the matter.</p>
<p>This isn’t to say that the pattern matching warning is unwelcome or that I want to avoid the pattern match because we have the struct update syntax… just that if I have a struct I don’t want to lose the discipline of treating it as such everywhere I might reference it.</p>
<p>And no, if it is deprecated I won’t lose too much sleep.</p>
<p>One final note on deprecation.  There are a number of libraries out there, some of them that get some use, but perhaps less maintenance.  While in some sense they may be “done” and not require a lot of attention, deprecations can cause a sudden requirement for attention which might not be readily available.  I still use libraries which cause warnings about charlists and not using the sigil, though for all intents and purposes they continue to work fine, if noisily during compile.  But these libraries aren’t looking like they’ll be updated anytime soon ether.  That’s the only concern that I really have given some of the thinness of support for some these things.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367023" 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/changes-to-the-struct-update-syntax/71232/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-367023" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367023"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="367027" data-post-id="367027">
  <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">
								<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyStruct do
  @moduledoc "module documentation"

  defstruct [:my_field]

  @typedoc "field documentation"
  @type my_field :: …

  @typedoc "struct documentation"
  @type t :: %__MODULE__{
          my_field: my_field()
        }

  # could be also done with a single and simple reduce similarly to for statement below
  @type field :: {:my_field, my_field()} | …
  @type fields :: [field()]

  @doc "put/2 documentation"
  @spec put(t(), fields()) :: t()
  def put(struct, fields), do: struct(struct, fields)

  @doc "put/3 documentation"
  def put(struct, field_name, field_value)

  for field_name &lt;- [:my_field] do
    var = Macro.var(field_name, __MODULE__)
    @spec put(t(), unquote(field_name), unquote(var)) :: t()
    def put(struct, unquote(field_name), unquote(var)) do
      Map.put(struct, unquote(field_name), unquote(var))
    end
  end
end
</code></pre>
<p>With this code:</p>
<ol>
<li>We can easily create a generic macro if we want to do same thing for many modules.</li>
<li>We have ful LSP support, documentation and specification</li>
<li>We no longer need struct update syntax</li>
</ol>
<pre data-code-wrap="elixir"><code class="lang-elixir"># old
%User{user | address: "Earth"}

# new
User.put(user, :address, "Earth")
# or
User.put(user, address: "Earth")
</code></pre>
<p>There should be no problem with readability, code completion and so on … We already have a good patterns that we can follow, so there is really no need for a struct update syntax.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367027" 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/changes-to-the-struct-update-syntax/71232/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-367027" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367027"
                     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 #20"></div>
  </section>
</div>
    <div class="postbit" id="367029" data-post-id="367029">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just my ¢2.</p>
<p>I don’t have anything against <code>%User{user | age: user.age + 1}</code> syntax, but it feels counter-idiomatic to me beyond two main usecases: ① <code>User</code> is somewhat “more” than a structure and updates are nevertheless should pass through kinda validation (via <a href="https://hexdocs.pm/ecto/Ecto.html#module-changesets" rel="noopener nofollow ugc">Changesets</a> in <em>Ecto</em>, or via <code>Access</code> in <a href="https://hexdocs.pm/estructura/Estructura.html#coerce/3" rel="noopener nofollow ugc"><em>Estructura</em></a>,) and ② state management in GenServer callbacks. I personally very rare if never met floating-by structs being just updated in the wild.</p>
<p>Assuming that ① is covered by the respective helpers (direct update with <code>%_{_ | kv}</code> is nevertheless should be avoided at any cost,) we have ② left. Yesterday I managed to clean up my libraries from the not-yet-but-to-be-deprecated syntax and I can tell, one would not miss these endless <code>%__MODULE__{state | key: :value}</code> in <code>{:reply, …}</code> and <code>{:noreply, …}</code> clauses.</p>
<p>Theoretically I can relate to the opinion <code>%User{… | kv}</code> is more <em>suggestive</em>, but in real code in my experience it is not. 99% of cases are covered by ① and ② above, and in ① there is no such thing as a direct struct update, while in ② it’d be rather <code>%__MODULE__{… | kv}</code> than <code>%State{… | kv}</code>.</p>
<p>The 1% left should be IMHO covered by introducing helpers within the module declaring a struct, as José mentioned above.</p>
<p>That all being said, I am voting for less noise, specifically taking into account that inability to sweep the unclearance of the code under the rug of final “boom! it’s still a user struct!” would eventually but inevitably force us devs to write cleaner code avoiding updates of who-the-hell-knows-what-this-struct-is in 20 lines under it’s definition <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="367029" 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/changes-to-the-struct-update-syntax/71232/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-367029" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367029"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If as a result of the change, someone replaces this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def update(foo) do
  %Foo{foo | bar: "baz"}
end
</code></pre>
<p>with</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def update(foo) do
  %{foo | bar: "baz"}
end
</code></pre>
<p>is there a way to realise that <code>foo</code> is always a <code>Foo</code> and warn then that writing</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def update(%Foo{} = foo) do
  %{foo | bar: "baz"}
end
</code></pre>
<p>would be better? I think this is the main thing that would be lost by deprecating the syntax, if the result is code that might cause bugs by performing operations on any map/struct that happens to have the right keys, when the intention was only ever to operate on a specific struct.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367032" 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/changes-to-the-struct-update-syntax/71232/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-367032" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367032"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="367035" data-post-id="367035">
  <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">
								<p><strong>Edit</strong>: Sorry, I didn’t read carefully, my bad</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367035" 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/changes-to-the-struct-update-syntax/71232/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-367035" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367035"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #23"></div>
  </section>
</div>
</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/71232/load_more?page=3">Load more posts (52 remaining)</a>
</div></template></turbo-stream>