<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 16, 2018 at 11:53 AM, Dylan Baker <span dir="ltr"><<a href="mailto:dylan@pnwbakers.com" target="_blank">dylan@pnwbakers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Quoting Jason Ekstrand (2018-03-16 11:38:47)<br>
<span class="">> On Fri, Mar 16, 2018 at 11:28 AM, Dylan Baker <<a href="mailto:dylan@pnwbakers.com">dylan@pnwbakers.com</a>> wrote:<br>
><br>
</span><span class="">> intr_opcodes = {<br>
> 'nop': Intrinsic('nop', flags=[CAN_ELIMINATE]),<br>
> ...<br>
> }<br>
><br>
> I prefer this since each dictionary is clearly created without a function<br>
> obscuring what's actually going on. If you dislike having to repeat the<br>
> name you<br>
> could even do something like:<br>
> intr_opcodes = [<br>
> 'nop': Intrinsic('nop', flags=[CAN_ELIMINATE]),<br>
> ...<br>
> ]<br>
> intr_opcodes = {<a href="http://i.name" rel="noreferrer" target="_blank">i.name</a>: i for i in intr_opcodes}<br>
><br>
><br>
> I'm not sure what I think about this. On the one hand, having the dictionary<br>
> explicitly declared is nice. On the other hand, in nir_opcodes.py we have a<br>
> bunch of other helper functions we declare along the way to help with specific<br>
> kinds of opcodes. It's not as practical to do this if everything is inside of<br>
> a dictionary declaration.<br>
<br>
</span>Why not?<br>
<br>
def make_op(name, *args):<br>
return Intrinsic(name, foo='bar', *args)<br>
<br>
intr_opcodes = [<br>
make_op('nop', ...),<br>
]<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Because it's nice to keep the definition of the wrapper close to where it's used. <br></div></div><br></div></div>