3 ms·
> Even Tcl "uplevel" is better than Python's castrated lambda. Tcl, in its own way, is more powerful than both Ruby and Python in that only the syntax is a giv
by davidw 18y ago
> Even Tcl "uplevel" is better than Python's castrated lambda.
Tcl, in its own way, is more powerful than both Ruby and Python in that only the syntax is a given. There is nothing special about 'if', 'while', and other control structures, which are not syntax, but commands. Indeed, you can write your own control structure commands in Tcl itself, with 'do ... while' being a classic example.
- tptacek 18y agoYou can do the same thing in Japanese Tcl using blocks.
- j2d2 18y agoRuby's lambda is worse than Python's. Can you elaborate on why you think Python's lambda is castrated?
- brushbox 18y agoI think it is due to the statement/expression dichotomy that Python exhibits. Python's lambda doesn't allow the use of statements (correct me if I'm wrong I haven't written Python in a few years and they may have "fixed" this). Meanwhile Ruby only allows expressions too - the catch here is that everything in Ruby is an expression.
- staticshock 18y agoThey don't plan to fix this, it's part of the core philosophy
- duane 18y agoA lambda is traditionally a functional programming product--think Lambda Calculus. Functional programming doesn't have statements, and neither should lambdas. Or do you mean anonymous function, in which case you're right.
- kaens 18y agoA python "lambda expression" can effectively only be a one-liner - basically the return line of a function minus "return". That is why people consider them castrated - in most languages I'm aware of that have a "lambda" statement, it can be read as "create an anonymous function that executes this body of statements". In python it reads as "perform a simple transformation or calculation on or with these arguments", as that's all it's generally good for.