<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>