<div dir="ltr">Personally I&#39;m fully against the &quot;feature&quot;. I want to maintain control over if and when I return and what I return in that event, I certainly do not want to hand that control over to another function, the matter would likely be made worse in c++ because of stuff like constructors and destructors.<br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, 1 Aug 2025 at 05:23, Jan Schultke via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org">std-proposals@lists.isocpp.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I can see how there&#39;s motivation for such a feature, but I&#39;m not<br>
convinced the design you have is quite right.<br>
<br>
Kotlin is a language that got non-local returns right, in my opinion.<br>
A non-local return can only be performed using a lambda at the call<br>
site, so you can write:<br>
<br>
val x = y.getOr { return false }<br>
<br>
Since the non-local return is restricted to be visible at the call<br>
site, it&#39;s rather unproblematic. It&#39;s basically a do-expression except<br>
using a lambda.<br>
<br>
No matter the design, this feature is pretty powerful and hard to<br>
implement. It&#39;s not enough for a function to be inlined by the<br>
optimizer; the non-local return basically needs to be pulled out to<br>
the call site, on any build type, so the inlining must be 100%<br>
guaranteed. As much as I like Kotlin non-local returns, they seem like<br>
a bad fit for C++, and this proposal would die on the basis of<br>
implementation effort alone.<br>
<br>
You can get your unwrap() function with macros though, and there&#39;s<br>
still room in the language for &quot;hygienic macros&quot;. Macros are 100%<br>
guaranteed inlining in the frontend already, so they solve this whole<br>
issue trivially.<br>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div>

