News for hackers. Stuff that matters.
Re:TypeScript Is Surprisingly OK for Compilers by IshKebab on Friday August 18, 2023 @03:21AM (#37172318)
> picked up most of the ML featureset

It really hasn't. In this very post he had to use a visitor to work around the fact that switch isn't an expression.

JavaScript's support for iterators is also weirdly shit. It has `.map()` but that only works on arrays. You can't map an iterator!

Re:TypeScript Is Surprisingly OK for Compilers by andyferris on Friday August 18, 2023 @03:32AM (#37172384)
I think there’s an iterator proposal out there for JS with generic map, filter, etc.
Re:TypeScript Is Surprisingly OK for Compilers by bakkoting on Friday August 18, 2023 @04:39PM (#37181783)
You can now! The iterator helpers proposal is stage 3 and shipping in Chrome.

  (new Set([0, 1, 2])).values().map(x => x + 1).toArray()
You can also reduce, filter, find, etc.