<div dir="ltr"><div class="gmail_extra" style><br><div class="gmail_quote" style>On Sun, May 12, 2013 at 12:45 AM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":3ze" style>In current Python, decorator abuse can be a reasonable option:<br>


<br>
   @closure<br>
<div class="im" style>   def block():<br>
        self.rule()<br>
        self.ast['rules'] = self.last_node</div></div></blockquote></div><br>Buf for that to work, you'd still have to call:<br><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra" style>

block()</div><div class="gmail_extra" style><br></div></blockquote><div class="gmail_extra" style>And that would make it:<br><br></div></div><div class="gmail_extra" style>   @closure<br><div class="im">   def block():<br>

        self.rule()<br>        self.ast['rules'] = self.last_node<br>   block()</div><div><br></div></div>Which I think makes little sense to a human reader, at least not in the pythonic way, and less so when compared to my (map/reduce..functional).<br>

<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra" style><div style><br></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra" style>

<div style>closure(block)</div></div></blockquote><div class="gmail_extra" style><div style><br></div></div><div class="gmail_extra" style>Your proposal was the approach I previously used in Grako, and I deprecated it in favor of the currently standing state of things in Python, which is: </div>

<div class="gmail_extra" style><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra" style><b>If you want an executable block of code you can iterate upon, then define a (non-anonymous) function, and pass it to the iterator.</b></div>

</blockquote><div class="gmail_extra" style><br></div><div class="gmail_extra" style>Cheers.<br clear="all"><div style><br></div>-- <br><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b>
</div></div>