<div dir="ltr">And exactly the opposite in the following case.<div><br></div><div>#!/usr/local/bin/escript<br>%% -*- erlang -*-<br><br>-define(SOME_MACRO(Y), X = Y + 1).<br><br>main(_Args) -><br>    X = 14,<br>    ?SOME_MACRO(X).<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 28, 2021 at 4:37 AM Leonard B <<a href="mailto:leonard.boyce@lucidlayer.com">leonard.boyce@lucidlayer.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"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 27, 2021, 16:48 Michael P. <<a href="mailto:empro2@web.de" target="_blank">empro2@web.de</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, 14 Jan 2021 13:13:54 -0500<br>
Leonard B <<a href="mailto:leonard.boyce@lucidlayer.com" rel="noreferrer" target="_blank">leonard.boyce@lucidlayer.com</a>> wrote:<br>
<br>
> IE, if a variable is previously assigned within the outer scope use<br>
> that variable within the inner scope.<br>
> This, in my addled mind, makes more sense<br>
><br>
> EG:<br>
> %% X is from outer scope, L is from outer scope, V is local to comprehension<br>
> X = 5.<br>
> L = [1,2,3,4,5].<br>
> [V || {X, V} <- L].<br>
<br>
Done?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">This was a broken example. Excuse formatting, on mobile. Should have been.</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif;font-size:12.8px">> EG:</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">> %% X is from outer scope, L is from outer scope, V is local to comprehension</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">> X = 5.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">> L = [{1, a}, {2,b}, {3,c}, {4,d}, {5,e}].</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">> [e] =:= [V || {X,V}</span><span style="font-family:sans-serif;font-size:12.8px"> <- L].</span><br style="font-family:sans-serif;font-size:12.8px"></div><div dir="auto"><br></div><div dir="auto">What I was getting at is that for many newcomers the scoping of X is a surprise. I'm totally fine with this, and that possibly injecting variables from outer to inner scopes would be more 'logical'.</div><div dir="auto"><br></div><div dir="auto">Changing how scoping worked would probably be a huge change and have worse issues. It's just that in my mind I look at the eep and I personally see it boiling down to scoping.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
```<br>
Eshell V10.2.4  (abort with ^G)<br>
1> X = 5.<br>
5<br>
2> L = [1,2,3,4,5].<br>
[1,2,3,4,5]<br>
3> [V || {X, V} <- L].<br>
[]<br>
4> [{X, V} || V <- L, V /= X].<br>
[{5,1},{5,2},{5,3},{5,4}]<br>
<br>
5> Lt = [{1, 2}, {2, 3}, {4, 5}, {5, 6}, {6, 7}, {5, 8}].<br>
[{1,2},{2,3},{4,5},{5,6},{6,7},{5,8}]<br>
6> [V || {X, V} <- Lt].<br>
[2,3,5,6,7,8]<br>
7> [V || {Selector, V} <- Lt, Selector == X].<br>
[6,8]<br>
```<br>
Names should be swapped (X, Selector).<br>
<br>
Naming is a burden; but also an opportunity.<br>
<br>
~M<br>
<br>
--<br>
<br>
Corporation-independent Public Broadcasting is the best innovation<br>
since someone said, that the volcano will erupt anyway or not, no<br>
matter how many virgins are thrown into it or not.<br>
<br>
Unternehmensunabhängiger Öffentlich-rechtlicher Rundfunk ist<br>
die beste Innovation, seit jemand sagte, dass der Vulkan eh<br>
ausbricht oder nicht, egal wieviele Jungfrauen man da reinwirft<br>
oder nicht.<br>
<br>
<br>
<br>
<br>
</blockquote></div></div></div>
</blockquote></div>