<br><br><div class="gmail_quote">On Mon, Jul 25, 2011 at 9:50 AM, 海韵 <span dir="ltr"><<a href="mailto:lyricconch@gmail.com">lyricconch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Dupilcate K is used only for describe the scope rule.<br>
Advantage:<br>
<br>
1.  the same grammer, the same behave<br>
"t" of  """(x+y as t, x-y as s) t * s + s + t""" is only valid in the<br>
expression which require<br>
just as<br>
"e" of """except ... as e""" only live in the suite which it belongs<br>
<br>
2. readability includes laconic<br>
a = (x+y as t, x-y as s) t * s + s + t<br>
it doesnt break thinking. from left to right, people finish thinking inplace.<br>
temp var will not keep in memory, people can forget them since they<br>
are not valid outside the expression. everything is clean.<br>
t, s = x+y,  x-y<br>
a = t * s + s + t<br>
in this case, thinking is break and temp var keep in memory,<br>
people should take some care about it (for example, in nested loop)<br></blockquote><div><br></div><div>(x + y) * (x - y) + 2 * x</div><div><br></div><div>is IMHO more readable - especially note the absence of y in the third term.</div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
3. this enchant the "lambda" syntax<br>
list.sort(key = lambda p: (sqrt(p.x**2+p.y**2) as r) r**2+ A*r + B)<br></blockquote><div><br></div><div>I don't know what "enchant" means here, but you can do this if you want:</div><div><br></div><div>list.sort(key = lambda p: (lambda r: r**2 + A*r + B) (sqrt(p.x**2+p.y**2)))</div>

<div><br></div><div>I'm not recommending that as I think it would be more readable to name that function so that it would be more clear why you're using that function as the sort key. But, to me, this example does not justify new syntax.</div>

<div><br></div><div>--- Bruce</div></div>