News for hackers. Stuff that matters.
Re:I Believe Zig Has Function Colors by cprecioso on Saturday April 09, 2022 @04:59AM (#30966352)
I enjoy Swift’s version of this, where you mark if a function can throw and you need to mark the callers up the chain until you handle those errors.

There’s also Haskell’s system, which IIRC uses an IO monad.

Re:I Believe Zig Has Function Colors by pjmlp on Saturday April 09, 2022 @05:12AM (#30966418)
An idea introduced by CLU, copied by Modula-2+, Modula-3, C++ and Java, and usually blammed on Java.

https://www.academia.edu/71720554/A_Modular_Verifiable_Excep...

Re:I Believe Zig Has Function Colors by saagarjha on Saturday April 09, 2022 @06:24AM (#30966752)
Re:I Believe Zig Has Function Colors by pjmlp on Saturday April 09, 2022 @08:14AM (#30967367)
Thanks, it was a bit hard to find one on the phone.
Re:I Believe Zig Has Function Colors by gpderetta on Saturday April 09, 2022 @04:10PM (#30971564)
C++ had a dynamically typed variant that was useless and got deprecated (and eventually dropped) a few standards ago.
Re:I Believe Zig Has Function Colors by pjmlp on Sunday April 10, 2022 @04:44AM (#30975397)
It was deprecated in C++11, and a removed in C++17, yet now they are discussing adding it back in a flavour similar to Swift, so apparently there is some value into it.

So here you go, http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p070...

As for being useless, well that is the usual argument from no exception, no RTTI folks, that would be better off using another language instead of messing up with C++'s design.

Re:I Believe Zig Has Function Colors by gpderetta on Sunday April 10, 2022 @05:14AM (#30975533)
I'm very much in favour of statically checked exceptions (and noexcept is sorta-kinda like that). It is the old dynamically typed style which was little more than an assertion that wasn't very useful.
Re:I Believe Zig Has Function Colors by inglor on Saturday April 09, 2022 @05:12AM (#30966417)
Haskell's system (with the io monad + do not all monads or in general) is extremely similar to async/await and most languages with co-routines can simulate do notation in Haskell pretty well syntactically.

The advantage of something like JavaScript's async/await over Haskell's "do" is the fact because async/await is more limited than `do` (or yield and coroutines in JS) it's a lot easier to create tooling for.

Re:I Believe Zig Has Function Colors by kaba0 on Saturday April 09, 2022 @05:37AM (#30966520)
I would say it is a huge disadvantage -- do is just syntactic sugar for a monad expression of binds, which is a native part of the language, you can write a simple function to manipulate it however you like. While you would need to effectively parse AST in case of JS.
Re:I Believe Zig Has Function Colors by inglor on Saturday April 09, 2022 @07:37AM (#30967139)
`yield` is just syntactic sugar for the two-way generator communication protocol where the consumer calls `.next(value)` which returns a value in turn. This is as expressive and you can build `do` semantics on top of stuff like lists/either/state/io on top of it. No AST parsing needed.
Re:I Believe Zig Has Function Colors by kaba0 on Saturday April 09, 2022 @08:20AM (#30967403)
And do syntax sugar is just nested calls of `bind` which is a function of the Monad trait. Lists are also a Monad, so do notation just works right now with lists, either, state everything in Haskell.

I really don’t get how is Haskell “behind”.

Re:I Believe Zig Has Function Colors by ImprobableTruth on Saturday April 09, 2022 @06:06AM (#30966653)
> async/await is more limited than `do` (or yield and coroutines in JS) it's a lot easier to create tooling for.

What kind of tooling are you referring to?

Re:I Believe Zig Has Function Colors by inglor on Saturday April 09, 2022 @07:38AM (#30967150)
Basically by limiting the scope significantly and limiting it to language-level Promises you can create things like zero-cost async stack traces, async-call aware flame graphs and more for analysis and better lint rules and more specific types for development.