<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>I couldn't agree more with Hugo & Richard - <br>
</p>
<p>We are programming in a high level language here; you shouldn't
be trying to compact your code unless you are <i>trying </i>to
obfuscate it. <br>
</p>
<p>And as far as I understand it,<b> the compiler is going to make
those substitution optimizations for you</b>. <br>
</p>
<div class="moz-cite-prefix"><a moz-do-not-send="true"
href="http://blog.erlang.org/core-erlang-optimizations/">http://blog.erlang.org/core-erlang-optimizations/</a><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">So absolutely, line up your variables
nicely, give them good names, keep things in short & make it
readable. <br>
</div>
<div class="moz-cite-prefix">Other peeps, & more probably your
future-self, will thank you. <br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">All this is great Erlang coding
technique and solid habits to be forming. <br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">- Rob C. <br>
</div>
<div class="moz-cite-prefix"><font size="-1"><i>scriptculture.com </i></font><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">On 3/14/19 6:35 PM, Hugo Mills wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20190314223550.GC10520@carfax.org.uk">
<pre class="moz-quote-pre" wrap="">On Thu, Mar 14, 2019 at 06:12:35PM -0400, Donald Steven wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Sometimes, when a variable is bound then used only once in a
function call, it seems easier just to just use what it is bound to
directly in the function call, bypassing the first step.
Here's an example:
getSound(Event) ->element(evaluate:probableElement(evaluate:probabilities(<a class="moz-txt-link-freetext" href="maps:get(elementTag">maps:get(elementTag</a>,
Event))),
hd(lists:nth(<a class="moz-txt-link-freetext" href="maps:get(templateTag">maps:get(templateTag</a>, Event),
agitatedSoundResources(<a class="moz-txt-link-freetext" href="maps:get(scalarTag">maps:get(scalarTag</a>, Event),
<a class="moz-txt-link-freetext" href="maps:get(registerTag">maps:get(registerTag</a>,
Event), <a class="moz-txt-link-freetext" href="maps:get(transpositionTag">maps:get(transpositionTag</a>, Event))))).
Alternatively, I could have declared, for example, a raft of
variable like ElementNumber, ElementTag, TemplateTag, etc.
I realize that this all-in-one-compact version tends towards
inscrutabel c code liek &X++ ?.
How do you approach the temptation to avoid discrete steps in favor
of compactness?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
I don't find it tempting at all. :)
The discrete steps can be useful documentation, because you can
give the interim variables meaningful names, explaining (a little)
what it is that you're doing.
It also helps to break up the calls for formatting and readability,
particularly if you have functions with multiple parameters in the
sequence.
Hugo.
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
</body>
</html>