Re:Go + Services = One Goliath Project
by saagarjha on Saturday December 21, 2019 @07:03PM
(#21854137)
That's a lot of boilerplate for a closure…
[ Parent
| on HN ]
The trivial lambda case is short, and you can do what the parent said if you want to do something that doesn't fit into the trivial lambda case well.
Re:Go + Services = One Goliath Project
by saagarjha on Saturday December 21, 2019 @07:13PM
(#21854191)
The "lambda" keyword isn't :(
Where's the boilerplate? "def b():" and "() => {}" are both 8 characters.
It is annoying that you have to give the function a name, though.
Re:Go + Services = One Goliath Project
by aserafini on Saturday December 21, 2019 @07:55PM
(#21854382)
On the one hand it’s annoying, on the other it enforces a discipline of thought in the same way that having to name variables does.
That’s an interesting principle, something like “a block of code that is complex enough to be written across multiple lines of code ought to be given a name,” but standard idiomatic Python already violates that principle by featuring multiple lines in the body of a for loop. The fact that the body of a for loop can be multiple lines but the “body” of a lambda cannot is an arbitrary syntax inconsistency.
def b(x):
return x + 1
vs x => x + 1
Re:Go + Services = One Goliath Project
by earenndil on Saturday December 21, 2019 @07:06PM
(#21854156)
def a(n):
return lambda: print(n)
Re:Go + Services = One Goliath Project
by saagarjha on Saturday December 21, 2019 @07:10PM
(#21854179)
That's a couple characters over most languages I normally use. Plus lambdas have a number of strange warts and restrictions (no multi-line lambdas?) that leave me feeling that Python really dislikes traditional functional programming constructs.