19 ms·
These are all really weird and not idiomatic. Most of your weird quibbles would be solved by just writing a type like const pt: [number, number] = [1, 2] As f
by chadlavi 4y ago
These are all really weird and not idiomatic. Most of your weird quibbles would be solved by just writing a type like
const pt: [number, number] = [1, 2]
As for piping functions... that's just how functions work. Not sure what the point of that piping syntactic sugar is.
- antonyt 4y agoIt doesn’t have to be the only way that functions work. Pipeline operators are idiomatic in other languages, and the linked proposal in that section of the article is worth reading.
- chadlavi 4y agoSure, but not in JavaScript.
- jonwest 4y agoI’m admittedly not primarily a TS dev, but I agree with your points completely. Even though you’re reading the piped functions right to left, and most code is going to be read from left to right, in order for a parameter to be passed like a value it’s gotta be computed. If I’m solving a math equation, I know that I need to follow the order of operations—I don’t need to rewrite the equation in an entirely new way. It’s more intuitive for me, at least, to wrap my head around the current approach.
- bigDinosaur 4y agoIt takes about thirty seconds to become used to writing nested function calls as a pipe - it's purely syntactic sugar. It's not what I'd call an 'entirely new way' in the sense that changes nothing about evaluation order or anything like that.
- gforge 4y agoThe pipe is one of those things that once you've tried it you never want to go back. The pipe came to R a few years back and I would argue that it is one of the best features. I admit that data munging is a very stepwise process but I find myself frequently missing it in Ts when I code. It makes the code denser as you use fewer intermediate variables while the code id still easy to debug.