<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">At one extreme we reach the 'point-free' style liked in Haskell,</div><div class="gmail_default" style="font-family:monospace,monospace">or the 'pipeful' style common in F#.</div><div class="gmail_default" style="font-family:monospace,monospace">There is a place for that sort of thing,</div><div class="gmail_default" style="font-family:monospace,monospace">but I'm not convinced that code meant for other people</div><div class="gmail_default" style="font-family:monospace,monospace">to read is that place.</div><div class="gmail_default" style="font-family:monospace,monospace">Think of introducing variables as an opportunity to make</div><div class="gmail_default" style="font-family:monospace,monospace">your code easier to understand, not as a cost.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 15 Mar 2019 at 11:36, Hugo Mills <<a href="mailto:hugo@carfax.org.uk">hugo@carfax.org.uk</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">On Thu, Mar 14, 2019 at 06:12:35PM -0400, Donald Steven wrote:<br>
> Sometimes, when a variable is bound then used only once in a<br>
> function call, it seems easier just to just use what it is bound to<br>
> directly in the function call, bypassing the first step.<br>
> <br>
> Here's an example:<br>
> <br>
> getSound(Event) ->element(evaluate:probableElement(evaluate:probabilities(maps:get(elementTag,<br>
> Event))),<br>
> hd(lists:nth(maps:get(templateTag, Event),<br>
> agitatedSoundResources(maps:get(scalarTag, Event),<br>
> maps:get(registerTag,<br>
> Event), maps:get(transpositionTag, Event))))).<br>
> <br>
> Alternatively, I could have declared, for example, a raft of<br>
> variable like ElementNumber, ElementTag, TemplateTag, etc.<br>
> <br>
> I realize that this all-in-one-compact version tends towards<br>
> inscrutabel c code liek &X++ ?.<br>
> <br>
> How do you approach the temptation to avoid discrete steps in favor<br>
> of compactness?<br>
<br>
I don't find it tempting at all. :)<br>
<br>
The discrete steps can be useful documentation, because you can<br>
give the interim variables meaningful names, explaining (a little)<br>
what it is that you're doing.<br>
<br>
It also helps to break up the calls for formatting and readability,<br>
particularly if you have functions with multiple parameters in the<br>
sequence.<br>
<br>
Hugo.<br>
<br>
-- <br>
Hugo Mills | The most exciting phrase to hear in science, the one<br>
hugo@... <a href="http://carfax.org.uk" rel="noreferrer" target="_blank">carfax.org.uk</a> | that heralds new discoveries, is not "Eureka!", but<br>
<a href="http://carfax.org.uk/" rel="noreferrer" target="_blank">http://carfax.org.uk/</a> | "That's funny..."<br>
PGP: E2AB1DE4 | Isaac Asimov<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.12 (GNU/Linux)<br>
<br>
iQIcBAEBAgAGBQJcitdGAAoJEFheFHXiqx3khsgP/2+gnwII70wb5JGoX4i+U78F<br>
/aLbdSA7mtYDlXJDevPmwAr0unZZOG4A+EM8pytRXLmN1lxanOU5Ja1LIsDTWJFP<br>
AsjwbAH2pVtdFerwug6braBFNyD+vyoPpYo3lni+UnmDmaeCTR88C9np5Nvi07bZ<br>
TJRVoi5Sx7pRo5m4P2v2O2diTb/Gt8Xxk+zkvOzo5obSAsB8bzLhDiL/fVnCR91m<br>
6Z4bk2eL/iVvuYqhVQmpIrMDGJvzzqW1POuevoE7+/HdScFzHv8Xow3XxDmPC3TT<br>
r/04lviaZounef0mymNsVILmsQUzpF/ZMq3X8KLddbFovqRLbxyYmtgiMs8iyfvF<br>
0tbKfM53Y+LbKvRdmVe50lDVR1C8KAPvpUO+piFh3lP5aOK9r8vK0v5R9v9exMwp<br>
yNqspsNZk6iTnF4Mxaa2P80vHM2DmAfdiKYLZb9gqJKXbuC9g1t2g6z+1GP1Y9JS<br>
HuUaTX3ed0zdzmNWT7YxaSsWi6TJp9lhTH4gcfqNLmvr4wgsgPABD1KqoOgverrZ<br>
yJcwEKk2xuuZt5xLvNdJacN1VWZS/ybQiko022JR4iXV1nXoz/P8tR1rx+tKez2u<br>
y3gqdrPVA4XT/X8j+YrkLm3G2v1XJy6+ANO2oe+Iz41vgi0EtbVywZZKyChUry6u<br>
Qpsht+QWZofR+vdWzk4Q<br>
=fKS8<br>
-----END PGP SIGNATURE-----<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>