LWN: Comments on "Alternative syntax for Python's lambda" https://lwn.net/Articles/847960/ This is a special feed containing comments posted to the individual LWN article titled "Alternative syntax for Python's lambda". en-us Fri, 29 Aug 2025 17:26:38 +0000 Fri, 29 Aug 2025 17:26:38 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Alternative syntax for Python's lambda https://lwn.net/Articles/853223/ https://lwn.net/Articles/853223/ flussence <div class="FormattedComment"> <font class="QuotedText">&gt;Does anyone want to be where Raku is today?</font><br> <p> It&#x27;s the easiest way today (and for the past 6 years or so) to run Python 2 and 3 code in an environment with modern quality-of-life features like arrow functions, switch statements and threads. I&#x27;m sure there&#x27;s demand for that somewhere.<br> </div> Sun, 18 Apr 2021 10:28:44 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/852908/ https://lwn.net/Articles/852908/ hummassa <div class="FormattedComment"> Raku is actually an useful language to learn and use today. Yes, it does not have the (deserved) place in the pantheon that Python has. It has to maturate its tools (yay more compiler optimizations) and its frameworks. I use it regularly, and with nice results on my field (data integration and analysis).<br> </div> Fri, 16 Apr 2021 11:02:42 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/852794/ https://lwn.net/Articles/852794/ wtanksleyjr <div class="FormattedComment"> Does anyone want to be where Raku is today? Or for that matter where Perl plus Raku is today? Perl has lost steam since 2005-ish, and Python only just stepped up circa 2018. Python didn&#x27;t eat Perl&#x27;s lunch; it looks like something that&#x27;s internal to Perl itself.<br> </div> Thu, 15 Apr 2021 20:20:57 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/851297/ https://lwn.net/Articles/851297/ mina86 <div class="FormattedComment"> <font class="QuotedText">&gt; but it led &quot;Random832&quot; to suggest looking at the &quot;-&gt;&quot; or &quot;=&gt;&quot; arrow</font><br> <font class="QuotedText">&gt; operators used by other languages, such as C#, Java, and JavaScript.</font><br> <p> <font class="QuotedText">&gt;&gt; It&#x27;s worth noting that all three of these are later additions to</font><br> <font class="QuotedText">&gt;&gt; their respective languages, and they all have earlier, more</font><br> <font class="QuotedText">&gt;&gt; difficult, ways of writing nested functions within</font><br> <font class="QuotedText">&gt;&gt; expressions. Their designers saw the benefit of an easy lambda</font><br> <font class="QuotedText">&gt;&gt; syntax, why don&#x27;t we?</font><br> <p> I don’t know about C# but before lambda functions were introduced in<br> Java, one had to write dozens of lines to get a simple anonymous ‘x+y’<br> function. This is nothing like Python which has a short lambda<br> expression.<br> <p> And as for JavaScript, arrow functions have different semantics than<br> anonymous functions. The arrow function wasn’t introduced because<br> ‘function’ is such a long word but because programmers couldn’t<br> comprehend how ‘this’ variable worked. Again, this does not reflect<br> situation in Python.<br> <p> Neither comparison is apt.<br> <p> </div> Wed, 31 Mar 2021 20:53:13 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/850669/ https://lwn.net/Articles/850669/ quantzur <div class="FormattedComment"> The lambda function still doesn&#x27;t know it&#x27;s own name:<br> <p> <font class="QuotedText">&gt;&gt;&gt; def g(x): return x * 7</font><br> ...<br> <font class="QuotedText">&gt;&gt;&gt; g(4)</font><br> 28<br> <font class="QuotedText">&gt;&gt;&gt; g.__name__</font><br> &#x27;g&#x27;<br> <font class="QuotedText">&gt;&gt;&gt; list(map(f := lambda x: x * 7, [1, 2, 3]))</font><br> [7, 14, 21]<br> <font class="QuotedText">&gt;&gt;&gt; f(4)</font><br> 28<br> <font class="QuotedText">&gt;&gt;&gt; f.__name__</font><br> &#x27;&lt;lambda&gt;&#x27;<br> </div> Fri, 26 Mar 2021 14:29:33 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/850587/ https://lwn.net/Articles/850587/ strombrg <div class="FormattedComment"> <p> I&#x27;m opposed to terse-ifying lambda in Python.<br> <p> Lambda is rarely useful in Python - you&#x27;re almost always better off using a generator expression, a list comprehension, or something from the operator module.<br> <p> And lambdas tend to give rise to the software development equivalent of a runon sentence.<br> <p> Naming a function in those rare cases that you genuinely need something custom really isn&#x27;t the end of the world, and is more readable anyway.<br> <p> <p> </div> Thu, 25 Mar 2021 20:06:48 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/850236/ https://lwn.net/Articles/850236/ nix <div class="FormattedComment"> Actually, a reference or two might be helpful. I&#x27;ve not really looked at the changes in C++ and what they imply for typical style since about 2000, and the language has moved on. I ought to catch up, but the relevant content appears to be scattered across hundreds of webpages each of which assumes you have read all the others first.<br> <p> If there really is a book somewhere discussing how C++ has changed and how typical style has changed, I&#x27;d be very interested, because modern C++ has at some point since C++11 dissolved for me from &quot;I can kind of read this if I squint&quot; to &quot;this is a pile of angle brackets and I really have no idea why they are here rather than somewhere else&quot;. So I think I have some relearning to do -- but from where?<br> <p> </div> Wed, 24 Mar 2021 00:00:58 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/850138/ https://lwn.net/Articles/850138/ kpfleming <div class="FormattedComment"> Yes, this exactly. It&#x27;s trivially easy to accidentally capture &#x27;this&#x27; in a lambda without extending the lifetime of that object.<br> </div> Tue, 23 Mar 2021 00:27:16 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/850117/ https://lwn.net/Articles/850117/ zlynx <div class="FormattedComment"> He probably means how you can define a C++ automatic reference capture lambda, then when it has a lifetime longer than those references the world blows up.<br> <p> Java&#x27;s garbage collection has a similar problem here though. Instead of exploding, your &quot;innocent and harmless&quot; capture holds a 300 MB data structure live in RAM.<br> <p> I&#x27;ve seen C++ lambda captures hold references after a function exits, after a thread exits and even after the program itself exits. Threads continue running even after static object destruction.<br> </div> Mon, 22 Mar 2021 21:31:18 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/850080/ https://lwn.net/Articles/850080/ hummassa Whoah? There is nothing <em>but</em> automatic memory management in C++, unless you are using <code>new</code> and <code>delete</code>, in which case I have a stack of books for you to read before you start over. Mon, 22 Mar 2021 16:52:02 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/850072/ https://lwn.net/Articles/850072/ hummassa <pre> &lt;Ctrl+k&gt;*l :help digraphs </pre> Mon, 22 Mar 2021 16:11:51 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/849336/ https://lwn.net/Articles/849336/ flussence <div class="FormattedComment"> A delayed language will eventually be good; a language that gets rushed to meet nonsense deadlines will become the legacy code everyone curses for decades to come.<br> <p> The most baffling thing to me about the whole epic of Raku isn&#x27;t how it concluded, but that as recently as last week I still see people who think they&#x27;re clever for regurgitating hateful Perl 6 FUD from the era when it was still called Perl 6, Slashdot was a relevant tech site, and comparisons to Duke Nukem Forever were still valid. The language is a good tool to write in, but it&#x27;s accidentally just as valuable for its ability to quickly expose the sort of people with ossified brains and odious worldviews most of us wouldn&#x27;t want anything to do with.<br> </div> Mon, 15 Mar 2021 07:37:50 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/849307/ https://lwn.net/Articles/849307/ cbensf <div class="FormattedComment"> Both would be valid choices in a fresh language, but in Python a lot of other choices have fallen into place to work better with them as functions.<br> <p> * map() and filter() should work on any iterable. In Ruby calling them as methods works by all iterables inheriting the Mixin `Enumerable` which keeps growing with time.<br> But in Python the iteratable/iterator protocols are frozen and extremely narrow. All you need is `__iter__` / `__next__`. This is a feature.<br> Consider `itertools` module — it extends the set of things you can do with iterators simply by exporting more functions, without adding methods to built-in types. Similarly, countless people have written functions processing iterators, sharing some on PyPI.<br> [To be fair, *in practice* the Ruby culture of monkey-patching causes surprisingly little problems! So it&#x27;s more cultural choice than technical argument.]<br> <p> * There is also a question of symmetry when consuming several iterables, e.g. `zip(foos, bars)` or even the little-known `map(operator.add, foos, bars)`. These would look less pretty as methods on the first sequence...<br> <p> * There are also various builtins &quot;reducing&quot; an iterable like `sum()`, `all()`, `any()`, `max()` etc. that combine pleasantly with generator expressions. E.g. to test if `n` is composable prime: `any(n % d == 0 for d in range(2, n))`.<br> In ruby this would be `(2...n).any? { |d| n % d == 0 }` which is a method on Enumerable that takes a block; so in Python this pattern of functions taking an iterator compensates for lack of blocks in some cases...<br> <p> * A deeper argument IMHO, is that Python has a long tradition of separating the protocol a class has to implement from the public interface one calls.<br> It does this by operators and global functions, which adds flexibility and helps evolve the language:<br> - `a &lt; b` operator started out in python 2 calling `a.__cmp__(b)` with fallback to `b.__rcmp__(a)`; later PEP 0207 added `a.__lt__(b)` and `b.__ge__(a)`.<br> - `bool()` checks `.__nonzero__()_` but falls back to `.__len__()`.<br> - `iter()` supports objects without `.__iter__` if they implement &quot;sequence&quot; protocol of `.__getitem__` with increasing integers. This allowed the for loop, but also everything else that wants to iterate, to keep working with older classes predating the iterator protocol.<br> - Even the trivial `.next()` method was wrapped in a builtin function `next()`, which helped abstract the later renaming to `.__next__` (PEP 3114).<br> <p> </div> Sun, 14 Mar 2021 12:49:43 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/849240/ https://lwn.net/Articles/849240/ HelloWorld <div class="FormattedComment"> Or one can just use one of the myriads of languages that got this right a decade or two ago (or 7 in the case of Lisp). <br> </div> Sat, 13 Mar 2021 13:53:14 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/849051/ https://lwn.net/Articles/849051/ kleptog <div class="FormattedComment"> Well, in Elixir (which I think lifted the syntax from Ruby) it would look like:<br> <p> range(5) |&gt; zip(reversed(range(5)) |&gt; map(lambda x, y: x + y)<br> <p> Underwater this is converted to:<br> <p> map(zip(range(5), reversed(range(5)), lambda x, y: x + y)<br> <p> There is something pleasing about having the operator between the operands, but I don&#x27;t think Python should go this route. It requires your entire standard library to be designed to make this work well. It&#x27;s most appropriate for functional languages.<br> </div> Thu, 11 Mar 2021 08:35:12 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848924/ https://lwn.net/Articles/848924/ fredrik In Gnome, and terminals like Alacritty, you use the generic unicode character shortcut, which is <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>u</kbd> followed by the unicode code point for lambda which is 03BB, which can be abreviated to 3bb, so basically: <blockquote><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>u</kbd> <kbd>3</kbd> <kbd>b</kbd> <kbd>b</kbd> <kbd>Space</kbd></blockquote> Easy as pie! 🙂 Wed, 10 Mar 2021 11:28:26 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848920/ https://lwn.net/Articles/848920/ anselm <blockquote><em>And C++ is one of the most successful languages of all time.</em></blockquote> <p> C++: The COBOL of the 1980s. </p> Wed, 10 Mar 2021 09:36:35 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848918/ https://lwn.net/Articles/848918/ mpr22 <div class="FormattedComment"> .... personally, I think the answer should be &quot;the ugaritic cuneiform one&quot; :D<br> </div> Wed, 10 Mar 2021 09:12:50 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848911/ https://lwn.net/Articles/848911/ pj <div class="FormattedComment"> I use kitty as a terminal and have a hotkey for unicode input where I can then type in the long name and choose it from a list. This brings up... which lambda?<br> <p> U+39b is greek capital lambda<br> U+3bb is greek small letter lambda<br> U+1d27 is greek letter small capital lambda<br> <p> ...or one of the other 10ish mathematical lambda characters? (list at https://unicode-table.com/en/search/?q=lambda )<br> <p> Is there a convention for this? is one more canonical than the others?<br> </div> Wed, 10 Mar 2021 03:50:31 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848900/ https://lwn.net/Articles/848900/ milesrout The first solution is entirely doable. It's not hard to formally specify how indentation and whitespace inside indentation-insensitive expressions would work in a way that is quite intuitive, and where writing something that doesn't parse gives you an *error* instead of failing silently. <p> The way it works currently in Python (or at least you can conceptualise it this way to produce exactly the same result) is that the scanner/lexer parses each token, including whitespace tokens. Then it joins 'continuation lines' joined by backslashes, determines initial whitespace at the beginning of each line and then basically deletes the remaining whitespace, converting it into newline, indent and dedent tokens. Then any indent/dedent/newline tokens inside parens are deleted, so that this continues to work: <pre> x = foo(1, 2) </pre> That's seen by the parser as <pre> x = foo ( 1 , 2 ) NEWLINE. </pre> not as <pre> x = foo ( 1 , NEWLINE INDENT 2 ) NEWLINE DEDENT. </pre> It would be quite simple: mark every newline and indent within a particular depth of bracketing with that depth, and then ignore any indents of greater depth than the current level of bracketing while parsing, and insert virtual dedent tokens when going down levels of nested bracketing. <p> so that would be <pre> x = foo ( 1 , NEWLINE1 INDENT1 2 DEDENT1 ) NEWLINE </pre> so if you had in fact written <pre> x = foo(if True: 2 else: 3) </pre> you'd get <pre> x = foo ( if True : NL1 IN1 2 NL1 DE1 else : NL1 ID1 3 NL1 DE1 ) NL1 </pre> From the perspective of whatever is parsing at the top level, that's: <pre> x = foo ( [arbitrary tokens] ) NL </pre> and from the perspective of whatever is parsing inside the parens, that's: <pre> if True : NL IN 2 NL DE else : NL ID 3 NL DE </pre> which is exactly what you get if you parse that statement at a top level in Python currently (at least conceptually): <pre> if True: # if True : NL 2 # IN 2 NL else: # DE else : NL 3 # IN 3 NL # DE </pre> It's also really easy to implement. I have done so myself as a proof of concept, which I later turned into the parser for a scripting language that is basically Python-with-multi-line-lambdas. It's a few extra lines in the scanner and a few extra lines in the parser. It doesn't slow anything down from a computational complexity perspective. And as a bonus, it gives you a hard error rather than silently-do-the-wrong-thing if you get nested indentation wrong. <p> I know it's a really popular meme in the Python community that it's OMG2HARD4ME to do multi-line lambdas in a way that gives intuitive, hard-to-get-wrong do-what-I-mean results and is easy and efficient to implement, but as far as I can tell it's just not true. <p> It would be massively useful. It wouldn't just give multi line lambdas, it would give the ability to nest any expression inside any other expression. All the Python special cases, like generator expressions (just use <code>(for x in y: f(x))</code>), <code>a if b else c</code> (just use a proper if statement, although that would be forced to be on at least 2 lines), etc. could be deprecated and phased out eventually. <p> Of course it will never happen in Python because it's remarkable conservative about syntax that actually matters while wildly liberal with making relatively useless syntax changes like <code>:=</code>. [You could just write <code>foo((x = 1))</code> with my suggestion, by the way, which is a far nicer way of doing it than <code>:=</code>...] Wed, 10 Mar 2021 02:43:09 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848899/ https://lwn.net/Articles/848899/ milesrout <div class="FormattedComment"> The font faces we use today are not very much like the characters developed for convenience when writing &quot;using quill pens on animal-skin parchment&quot;. Letter forms change drastically with every new medium of writing. When symbols were chiseled into stones you get sharp and angular runes. When symbols are pressed into clay with a stylus you get wedge-shaped cuneiform. When symbols are painted onto paper with brushes you get the calligraphic Chinese script. When symbols are painstakingly carved into elaborate burial chambers you get the exquisite Egyptian hieroglyphs. When the same symbols are hastily jotted onto papyrus with a reed pen you get hieratic.<br> <p> When symbols are carved into a wax tablet you get what became our UPPERCASE latin alphabet, generally big sharp uncomplicated lines. When the same symbols are drawn onto a parchment or papyrus with a pen, you get the old Roman cursive, which basically became our lowercase. <br> <p> The letterforms in modern fonts aren&#x27;t even that similar to the script/cursive forms people use in handwriting today (see &#x27;a&#x27; or &#x27;g&#x27;).<br> <p> I honestly believe that programmers would use more unicode symbols if the input methods were better. Is that actually a good thing? There are a lot of Unicode confusables after all...<br> </div> Wed, 10 Mar 2021 02:08:58 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848896/ https://lwn.net/Articles/848896/ milesrout <div class="FormattedComment"> <font class="QuotedText">&gt;I&#x27;d prefer them to be methods rather than functions.</font><br> <p> This is not and will never be a good idea. So-called &#x27;UFCS&#x27; proposals have failed repeatedly in C++ for good reason, and in Python. Standalone functions are not methods and the method syntax is ugly and misleading. Prioritising one argument over others nearly always makes no sense, and even when it does it&#x27;s rare that it would be the first argument anyway. Why would it be `foo.map(lambda: ...)` or `foo.map(lambda: ..., bar)` and not `(lambda: ...).map(foo)` or `(lambda: ...).map(foo, bar)`? <br> <p> I think that it is obvious that we should stick to calling functions as `f(x, y, z)` as we have done in many programming languages for decades and in mathematics for hundreds of years. `x.f(y, z)` makes no sense. `a.plus(b)` is just hideously ugly compared to `plus(a, b)`, and it&#x27;s totally backwards anyway. If you were going to change to anything it should be `a b plus`, as then at least things would be evaluated entirely left-to-right.<br> </div> Wed, 10 Mar 2021 01:44:28 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848895/ https://lwn.net/Articles/848895/ milesrout <div class="FormattedComment"> <font class="QuotedText">&gt;Python 2.7 reached its enormous popularity for being a great balance of complexity and ease of use, which led to PyPI, and it&#x27;s current status of tool-of-choice for a massive number of programmers. But there were a couple of warts that just annoyed people enough that it was decided to break things, just this once, to fix them.</font><br> <p> This is revisionist nonsense. Python 3 development was started long before Python 2.7 existed. PyPI dates back to at least 2003, before Python 2.4 was released, let alone 2.7 (which wasn&#x27;t released until 2010, seven years later). Meanwhile, Python 3 was first officially released in 2008, but had been floating around as an idea since at least 2006 if not earlier. PEP3000 dates to April 2006, and---as far as I know---was not the first suggestion of a backwards incompatible Python release.<br> </div> Wed, 10 Mar 2021 01:38:06 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848846/ https://lwn.net/Articles/848846/ NYKevin <div class="FormattedComment"> How would you propose we rewrite the following?<br> <p> map(lambda x, y: x + y, range(5), reversed(range(5)))<br> <p> I&#x27;m not sure that range(5).map(lambda x, y: x + y, reversed(range(5))) is an improvement. And I&#x27;m definitely not writing zip(range(5), reversed(range(5)).starmap(lambda x, y: x + y), because that&#x27;s just ridiculous.<br> </div> Tue, 09 Mar 2021 17:32:35 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848843/ https://lwn.net/Articles/848843/ NYKevin <p> The problem with that is, if you accidentally have any value to its immediate left, then it already parses as a very different expression: <pre> &gt;&gt;&gt; import ast &gt;&gt;&gt; print(ast.dump(ast.parse('z |x, y| x + y - 2', mode='eval'), indent=4)) Expression( body=Tuple( elts=[ BinOp( left=Name(id='z', ctx=Load()), op=BitOr(), right=Name(id='x', ctx=Load())), BinOp( left=Name(id='y', ctx=Load()), op=BitOr(), right=BinOp( left=BinOp( left=Name(id='x', ctx=Load()), op=Add(), right=Name(id='y', ctx=Load())), op=Sub(), right=Constant(value=2)))], ctx=Load())) </pre> <p> (The indent= argument to ast.dump() requires Python 3.9+ for pretty-printing.) <p> That's not necessarily a complete non-starter, seeing as the lambda syntax probably would not allow you to put a value there, but it would be awkward if a small typo (e.g. omitting a comma) would result in a parse like that. Unfortunately, you can't just say "Well, x and y are non-existent variables, so don't parse it like that." An unrecognized variable is currently interpreted as an uninitialized global; it's assumed that said global will exist by the time the function is actually called (or else it's a <em>runtime</em> error). Python needs to continue to support that use case, or else recursive function calls won't work (functions are "just" variables that point at function objects). Tue, 09 Mar 2021 17:07:02 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848749/ https://lwn.net/Articles/848749/ nybble41 <div class="FormattedComment"> <font class="QuotedText">&gt; On KDE, systemsettings allows you to pick a key to use as XComposeKey.</font><br> <p> Yes, that&#x27;s how I have it configured. In other desktop environments you can use &quot;setxkbmap -option compose:menu&quot; (plus your normal model/layout options) for the same effect.<br> <p> <font class="QuotedText">&gt; I don&#x27;t think the env vars you are exporting are needed.</font><br> <p> If you don&#x27;t set them then both Gtk and Qt will pick a default input method. If that happens to be XIM then everything will work just fine. If not, the .XCompose file might be ignored; it depends on which input method was chosen. IBUS has some support for reading .XCompose in recent versions. I&#x27;m not sure about the others.<br> </div> Mon, 08 Mar 2021 23:17:07 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848646/ https://lwn.net/Articles/848646/ msuchanek <p>Somewhat off-topic, but to me, the syntax of map and filter is a bigger issue than lambda. I'd prefer them to be methods rather than functions.</p> <p>This is pretty hard for me to read:</p> <pre>&gt;&gt;&gt; map(lambda x: x + 1, range(5))</pre> <p>The lambda blends into the arguments and the comma is weak as a visual separator.</p> <p>This would much easier:</p> <pre>&gt;&gt;&gt; range(5).map(lambda x: x + 1)</pre> <p>Could that be partly to blame for the complaints about the lambda syntax?</p> Mon, 08 Mar 2021 12:16:46 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848574/ https://lwn.net/Articles/848574/ marcH <div class="FormattedComment"> Maturity: when you ran out of important things to do and finally have time to discuss pointless changes.<br> </div> Sun, 07 Mar 2021 00:15:00 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848539/ https://lwn.net/Articles/848539/ Deleted user 129183 <div class="FormattedComment"> <font class="QuotedText">&gt; There&#x27;s a point where you need to start working on a new language</font><br> <font class="QuotedText">&gt; I would love to have a Python 4.0 which is a feature freeze of Python 3.x, and the announcement of Snake-0.3b1: like Python but with X and Y and also Z!</font><br> <p> Erm…<br> <p> *looks at ~Perl 6~ Raku*<br> <p> I don’t think that it’s actually a great idea.<br> <p> (and I mean its adoption, not the language itself)<br> </div> Sat, 06 Mar 2021 15:23:33 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848521/ https://lwn.net/Articles/848521/ LtWorf <div class="FormattedComment"> On KDE, systemsettings allows you to pick a key to use as XComposeKey.<br> <p> I don&#x27;t think the env vars you are exporting are needed. I do not have them.<br> <p> It used to be that GTK did not support longer sequences than 2 so I had to write them in kwrite and copy paste, but it seems to be working now for a while.<br> </div> Sat, 06 Mar 2021 09:55:06 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848513/ https://lwn.net/Articles/848513/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; Having these things as words gives us words to talk about them and I don&#x27;t have to know if it&#x27;s an arrow or a pointer or a cursor.</font><br> <p> ... and for that reason everyone and will keep calling the new arrow notation... &quot;lambda&quot;! So much for &quot;beginner-friendliness&quot;.<br> <p> The beginner-friendly name is &quot;anonymous function&quot; but good luck getting non-beginners used to something that long.<br> <p> <font class="QuotedText">&gt; &gt; &gt; [It&#x27;s] no more &quot;magic&quot; than tuple, deque, iterator, coroutine, ordinal, modulus, etc, not to mention those ordinary English words with specialised jargon meanings like float, tab, zip, thread, key, promise, trampoline, tree, hash etc.</font><br> <p> Nice one.<br> <p> <p> </div> Sat, 06 Mar 2021 07:04:17 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848514/ https://lwn.net/Articles/848514/ aeline <div class="FormattedComment"> I agree I really like this syntax (although I think Ruby had it first)<br> It feels very visually distinct from tuples, which I think is plus.<br> </div> Sat, 06 Mar 2021 07:03:38 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848506/ https://lwn.net/Articles/848506/ aeline <div class="FormattedComment"> DrRacket also allows most unicode, by typing \latexcode and pressing Cmd-Enter.<br> This is really nice for following mathematics/language papers. A snippet from a recent project:<br> ;; Values<br> (v ::= n<br> b<br> ∅ ;; Unit<br> (λ (x : t) e) ;; Value Abstraction<br> (Λ x e)) ;; Type Abstraction<br> </div> Sat, 06 Mar 2021 01:54:02 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848504/ https://lwn.net/Articles/848504/ aeline <div class="FormattedComment"> In emacs and DrRacket that hotkey Cmd-\ <br> </div> Sat, 06 Mar 2021 01:49:35 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848495/ https://lwn.net/Articles/848495/ mbunkus <div class="FormattedComment"> While not built-in, I&#x27;ve been using the nice little Open Source program WinCompose[1] for quite a while now on Windows. It&#x27;s easily configurable, both regarding the sequences as well as the key to use as the compose key, and it comes pre-configured with a wide range of sequences, a lot of which match the traditional XCompose sequences.<br> <p> [1] <a href="http://wincompose.info">http://wincompose.info</a><br> </div> Fri, 05 Mar 2021 23:58:09 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848479/ https://lwn.net/Articles/848479/ flussence <div class="FormattedComment"> If Python starts a clean break and major refactoring to clean up 3.x&#x27;s myriad gobbledygook syntax extensions right now, using all the resources and prior art available to them, then it&#x27;ll be caught up to where Raku is today in significantly less time than the 20 years of effort that took. Maybe optimistically it&#x27;d be 5 years. *If*.<br> <p> If it doesn&#x27;t, well… people already complain that it&#x27;s the new Fortran but at this rate it&#x27;s going to be the new PHP too. Looking forward to that next “fractal of awfulness” blogpost…<br> </div> Fri, 05 Mar 2021 22:13:01 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848473/ https://lwn.net/Articles/848473/ mpr22 <div class="FormattedComment"> I use LeftWin for Compose myself. It&#x27;s a lot easier to reach fluidly than Menu on a standard-pitch 104/105 key keyboard.<br> </div> Fri, 05 Mar 2021 21:43:45 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848468/ https://lwn.net/Articles/848468/ nybble41 <div class="FormattedComment"> I type λ using the XCompose input method. That&#x27;s with this entry in my custom .XCompose file[0]:<br> <p> &lt;Multi_key&gt; &lt;g&gt; &lt;r&gt; &lt;l&gt; : &quot;λ&quot; U03BB # GREEK SMALL LETTER LAMBDA<br> <p> Here are the equivalents for lowercase a-z: αβ_δεφγηιθκλμνοπχρστυ_ωξψζ (&#x27;c&#x27; and &#x27;v&#x27; have no corresponding entries and so were replaced with &#x27;_&#x27;).<br> And the equivalents for uppercase A-Z: ΑΒ_ΔΕΦΓΗΙΘΚΛΜΝΟΠΧΡΣΤΥ_ΩΞΨΖ.<br> Also many useful symbols: → ⇒ ↑ ↓ × ÷ « » ⋄ ⊛ Ⓧ ¾ ⅞ ☺ € ₡ ¢ ∀ ∃ ±<br> <p> Unfortunately Windows doesn&#x27;t have any built-in equivalent to XCompose. I have a few char codes memorized for that, but λ isn&#x27;t one of them.<br> <p> To make this work under Linux with X11 you need to create the file ~/.XCompose, set GTK_IM_MODULE=xim and QT_IM_MODULE=xim, and assign some key to the Multi_key function in your keyboard settings. I use the Menu key for Multi_key but you might prefer something else.<br> <p> [0] <a href="https://jessemcdonald.info/gogs/nybble/compose-config/raw/a5811b9b8811459dcb309c2926089ff0175fbf2f/.XCompose">https://jessemcdonald.info/gogs/nybble/compose-config/raw...</a><br> </div> Fri, 05 Mar 2021 21:35:14 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848462/ https://lwn.net/Articles/848462/ cpitrat <div class="FormattedComment"> Stupid question: how do you type it? Do you configure your editor to have a special shortcut? Do you know the char code by heart?<br> </div> Fri, 05 Mar 2021 19:39:07 +0000 Alternative syntax for Python's lambda https://lwn.net/Articles/848461/ https://lwn.net/Articles/848461/ amarao <div class="FormattedComment"> Can&#x27;t we use rust notation for closures? |x, y| x + y - 2?<br> <p> Rust has second form for closures with {}, but we can ignore those.<br> </div> Fri, 05 Mar 2021 19:18:27 +0000