<div class="gmail_quote">On Wed, Jul 15, 2009 at 2:55 AM, Greg Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
One such extension might be a "where" block. Applied<br>
to the current problem:<br>
<br>
  foo(f) where:<br>
    def f(x):<br>
      ...<br>
</blockquote><div><br>I
like this proposal much more than any of the previous proposals.  It
has some of the flavor of Lisp's "let", but puts the important line
first instead of at the end.  In a nutshell, it says "define these
symbols for this one line only".  On the downside, for the common case
of wanting to define a single function, the body of the function must
be indented twice.<br><br>I suggest the following grammar and meaning,
which would be referred to by the assignment, yield, return, and
expression statements:<br><br>where_expression ::= expression_list "where" ":" suite | expression_list<br><br><br>It evaluates as follows.<br><br>[return|yield|x=] expression_list where:<br>   suite<br>
<br>is roughly equivalent to:<br><br>def where_expression():<br>    suite<br>    return expression_list<br>[return|yield|x=] expression_list()<br><br><br>How about the following as additional syntactic sugar for the common one-function case?<br>
<br>x = blah(f) where def f(item):<br>   body_of_f<br><blockquote style="margin: 1.5em 0pt;">--<br>
Daniel Stutzbach, Ph.D.<br>
President, <a href="http://stutzbachenterprises.com/">Stutzbach Enterprises, LLC</a>
</blockquote></div></div>