<p dir="ltr">Doesn't this kind of violate Python's "one way to do it"?</p>
<p dir="ltr">(Also, sorry for the top post; I'm on mobile right now...)</p>
<p dir="ltr">--<br>
Ryan<br>
[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.<br>
<a href="http://kirbyfan64.github.io/">http://kirbyfan64.github.io/</a></p>
<div class="gmail_quote">On Jul 12, 2016 7:38 AM, "Stephan Houben" <<a href="mailto:stephanh42@gmail.com">stephanh42@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi list,</div><div><br></div><div>Here is my speculative language idea for Python:</div><div><br></div><div>Allow the following alternative spelling of the keyword `lambda':<br></div><div><br></div><div>λ</div><div><br></div><div>(That is "Unicode Character 'GREEK SMALL LETTER LAMDA' (U+03BB).")</div><div><br></div><div>Background:</div><div><br></div><div>I have been using the Vim "conceal" functionality with a rule which visually</div><div>replaces lambda with λ when editing Python files. I find this a great improvement in</div><div>readability since λ is visually less distracting while still quite distinctive.</div><div>(The fact that λ is syntax-colored as a keyword also helps with this.)</div><div><br></div><div>However, at the moment the nice syntax is lost when looking at the file through another editor or viewer.</div><div>Therefore I would really like this to be an official part of the Python syntax.</div><div><br></div><div>I know people have been clamoring for shorter lambda-syntax in the past, I think this is</div><div>a nice minimal extension.</div><div><br></div><div><br></div><div>Example code:</div><div><br></div><div>  lst.sort(key=lambda x: x.lookup_first_name())</div><div>  lst.sort(key=λ x: x.lookup_first_name())</div><div><br></div><div>  # Church numerals</div><div>  zero = λ f: λ x: x</div><div>  one = λ f: λ x: f(x)</div><div>  two = λ f: λ x: f(f(x))</div><div><br></div><div>(Yes, Python is my favorite Scheme dialect. Why did you ask?)</div><div><br></div><div>Note that a number of other languages already allow this. (Racket, Haskell).</div><div><br></div><div>You can judge the aesthetics of this on your own code with the following sed command.</div><div><br></div><div>  sed 's/\<lambda\>/λ/g'</div><div><br></div><div>Advantages:</div><div><br></div><div>* The lambda keyword is quite long and distracts from the "meat" of the lambda expression. </div><div>  Replacing it by a single-character keyword improves readability.</div><div><br></div><div>* The resulting code resembles more closely mathematical notation (in particular, lambda-calculus notation),</div><div>  so it brings Python closer to being "executable pseudo-code".</div><div><br></div><div>* The alternative spelling λ/lambda is quite intuitive (at least to anybody who knows Greek letters.)</div><div><br></div><div><br></div><div>Disadvantages:</div><div><br></div><div>For your convenience already noticed here:</div><div><br></div><div>* Introducing λ is introducing TIMTOWTDI.</div><div><br></div><div>* Hard to type with certain editors.</div><div>  But note that the old syntax is still available.</div><div>  Easy to fix by upgrading to VIM ;-) </div><div><br></div><div>* Will turn a pre-existing legal identifier λ into a keyword.</div><div>  So backward-incompatible.</div><div><br></div><div>Needless to say, my personal opinion is that the advantages outweigh the disadvantages. ;-)</div><div><br></div><div>Greetings,</div><div><br></div><div>Stephan</div></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div>