<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr">Just read it all through and totally agree, this is really very elegant. Lovely to see. If all goes well, is there a rough guideline for how long it would take for this extension to appear in mainline releases? (If that’s the plan!)</div><div dir="ltr"><br></div><div dir="ltr">Thanks!</div><div dir="ltr"><br><blockquote type="cite">On 19 Sep 2021, at 16:35, Gian Lorenzo Meocci <glmeocci@gmail.com> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div>the proposal and the implementation are pieces of art!</div><div>Thanks for your work.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 19 Sept 2021 at 17:02, Gian Lorenzo Meocci <<a href="mailto:glmeocci@gmail.com">glmeocci@gmail.com</a>> 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"><div dir="ltr">Thanks a lot for the link!<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 19 Sept 2021 at 16:40, Paulo F. Oliveira <<a href="mailto:paulo.ferraz.oliveira@gmail.com" target="_blank">paulo.ferraz.oliveira@gmail.com</a>> 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"><div dir="ltr">Hi, Gian.<div><br></div><div>You might be interested in reading [1], first shown to the Erlang world in [2] (there's more info. in the archives, if you search).</div><div><br></div><div>FYI, it is being hacked away, at this very moment, in SpawnFest 2021: <a href="https://github.com/spawnfest/eep49ers" target="_blank">https://github.com/spawnfest/eep49ers</a>.</div><div><br></div><div>Cheers.</div><div><br></div><div>- Paulo F. Oliveira</div><div><br></div><div>[1] <a href="https://github.com/erlang/eep/blob/master/eeps/eep-0049.md" target="_blank">https://github.com/erlang/eep/blob/master/eeps/eep-0049.md</a></div><div>[2] <a href="http://erlang.org/pipermail/eeps/2018-September/000554.html" target="_blank">http://erlang.org/pipermail/eeps/2018-September/000554.html</a><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 19 Sept 2021 at 14:37, Gian Lorenzo Meocci <<a href="mailto:glmeocci@gmail.com" target="_blank">glmeocci@gmail.com</a>> 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"><div dir="auto">I think that there isn't a generic solution for this problem. It’s time to introduce the 'with' operator in Erlang 😂</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il Dom 19 Set 2021, 09:06 Attila Rajmund Nohl <<a href="mailto:attila.r.nohl@gmail.com" target="_blank">attila.r.nohl@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
One way (I haven't actually tried to compile this, but hopefully you<br>
get the idea):<br>
<br>
get_nas_from_conf() -><br>
  try<br>
    {ok, Server} = get_radius_host(),<br>
    {ok, Port} = get_radius_port(),<br>
    {ok, Secret} = get_radius_secret(),<br>
    {Server, Port, Secret};<br>
  catch<br>
    error:{badmatch, E} -><br>
      E<br>
end.<br>
<br>
Of course, if the badmatch comes from the get_* functions, this<br>
construct might catch that too, but you might be able to  ensure this<br>
doesn't happen.<br>
<br>
Gian Lorenzo Meocci <<a href="mailto:glmeocci@gmail.com" rel="noreferrer" target="_blank">glmeocci@gmail.com</a>> ezt írta (időpont: 2021.<br>
szept. 18., Szo, 22:50):<br>
><br>
> Hi,<br>
> I have a function like this:<br>
><br>
> get_nas_from_conf() -><br>
> case get_radius_host() of<br>
> {ok, Server} -><br>
> case get_radius_port() of<br>
> {ok, Port} -><br>
> case get_radius_secret() of<br>
> {ok, Secret} -><br>
> {Server, Port, Secret};<br>
> E -> E<br>
> end;<br>
> E -><br>
> E<br>
> end;<br>
> E -><br>
> E<br>
> end.<br>
><br>
> Which is the best way to write this kind of function?<br>
><br>
> I'd like to have a with operator like in Elixir, to rewrite my function in this way:<br>
><br>
> get_nas_from_conf() -><br>
> with {ok, Server} <- get_radius_host(),<br>
> {ok, Port} = get_radius_port(),<br>
> {ok, Secret} = get_radius_secret() -><br>
> {Server, Port, Secret};<br>
> catch<br>
> {error, _Reason} = E -><br>
> E<br>
> end.<br>
><br>
> Any suggestion?<br>
><br>
> --<br>
> GL<br>
> <a href="https://www.meocci.it" rel="noreferrer noreferrer" target="_blank">https://www.meocci.it</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div>GL<br><a href="https://meox.github.io" target="_blank">https://www.meocci.it</a><br></div></div></div></div></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>GL<br><a href="https://meox.github.io" target="_blank">https://www.meocci.it</a><br></div></div></div></div></div>
</div></blockquote></body></html>