<div dir="ltr">Although I said I was over this never-ending topic, I thought I might say that:<br><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">let:<br></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
def block():<br> # do stuff<br>in:<br> closure(block)</blockquote><div style><br></div><div style>Would be well understood by many in in the Python and functional-language communities.</div><div style><br></div>
<div style>Cheers,</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, May 12, 2013 at 7:43 PM, Martin Morrison <span dir="ltr"><<a href="mailto:martin.morrrison@cantab.net" target="_blank">martin.morrrison@cantab.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div class="im"><div>On 13 May 2013, at 00:40, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>> wrote:</div>
<blockquote type="cite"><div>
<p dir="ltr">Now, do you have any constructive feedback on the PEP that still accounts for Python's lack of a standard location for passing callables to functions, or is this reaction simply a matter of "I don't want to have to type 'f' twice because I don't have to do that in other languages"?</p>
</div></blockquote></div><div>Moving past the outright negative feedback, and having only just seen the PEP, the proposed syntax did strike me as awkward and unintuitive. Maybe there is some explanation for why decorator-like syntax was used - if so, please do link me so I can read up.</div>
<div><br></div><div>What struck me though is that the proposed syntax limits the ability to have multiple "anonymous blocks" within a single statement. Instead, I was thinking some syntax like the following might be nicer:</div>
<div><br></div><div>in x = do_something(in_arg, success_hdlr, error_hdlr):</div><div> def success_hdlr(result):</div><div> ... # Do something with result</div><div> def error_hdlr(error):</div><div> ... # Do something with error</div>
<div><br></div><div>That is instead of a decorator-like syntax, make the "in" keyword reusable to introduce a new block, whose "argument" is a statement that can forward reference some names, which are then defined within the block. This allows multiple temporary names to be defined (each in a separate statement within the block).</div>
<div><br></div><div>Some further thought is required on whether only def (and maybe class) statements should be allowed within the "in" block. Although I guess there's technically nothing wrong with:</div><div>
<br></div><div>in x = y + z:</div><div> y = 12</div><div> z = 30</div><div><br></div><div>Other than it's a very verbose way of doing something simple. ;-) But maybe there are more useful examples?</div><div><br>
</div><div>Cheers,</div><div>Martin</div><br><blockquote type="cite"><div>
<p dir="ltr">Regards,<br>
Nick.</p></div></blockquote></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b>
</div>