<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Den tors 21 jan. 2021 kl 17:12 skrev Kostis Sagonas <<a href="mailto:kostis@cs.ntua.gr">kostis@cs.ntua.gr</a>>:<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 1/21/21 3:41 PM, Richard Carlsson wrote:<br>
> Some weird code becomes obvious when annotated.<br>
> <br>
> What does this line do?<br>
> <br>
> _ = [M = M:module_info(module) || M <- Needed],<br>
> <br>
> Oh, it's a multi-assertion!<br>
> <br>
> _ = [^M = M:module_info(module) || M <- Needed],<br>
<br>
I disagree.<br>
<br>
This is _exactly_ the kind of code where you do *not* want such an <br>
annotation. You want to rewrite this to something like:<br>
<br>
true = lists:all(fun (M) -> M =:= M:module_info(module) end, Needed),<br>
<br>
No matching is required here.<br></blockquote><div><br></div><div>I never said it was good code, did I? I said it was weird code, which *exists today* in the OTP codebase, and that thanks to the annotation it at least became more obvious what it did. Now that we see what it does, it's easier to say "this probably ought to be rewritten". Your version isn't great however, because when it crashes it won't reveal which M did not match, just that one of them didn't.</div><div><br></div><div dir="ltr"><div><div dir="ltr" class="gmail_signature"> /Richard</div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr"></div></div><div> </div></div></div>