News for hackers. Stuff that matters.
Re:Expectations for generics in Go 1.18 by masklinn on Thursday October 28, 2021 @06:31AM (#29024364)
> That's a peculiar observation, it's like saying Rust's borrow checker is magical because it needs language-level support. I mean, that's the point.

You can’t do borrow checking without language support (I think, at least not without a significantly more expressive type system) whereas Result is pretty much just a type, the features it uses are mostly non-exclusive, and those which are, are very much intended not to remain so (e.g. the `Try` trait for the `?` operator).

> Zig errors are composable: https://ziglang.org/documentation/master/#Merging-Error-Sets and later sections.

Not really? That’s just merging error sets, but you can’t say that you’ve got an error which originally comes from an other error, except by creating its dual and documenting it as such. Essentially your choices are full transparency or full type erasure.

Re:Expectations for generics in Go 1.18 by kristoff_it on Thursday October 28, 2021 @07:09AM (#29024643)
> Not really? That’s just merging error sets, but you can’t say that you’ve got an error which originally comes from an other error, except by creating its dual and documenting it as such. Essentially your choices are full transparency or full type erasure.

What you just described are error traces. They're generated by Zig auomatically for you, thanks also to the fact that errors are a special construct in the language.

Relevant langref passage:

https://ziglang.org/documentation/master/#Error-Return-Trace...

Re:Expectations for generics in Go 1.18 by Zababa on Thursday October 28, 2021 @07:20AM (#29024719)
Don't you need sum types/sufficiently powerful enums for Result though? Which, in a way, makes it a language feature.
Re:Expectations for generics in Go 1.18 by masklinn on Thursday October 28, 2021 @09:22AM (#29025801)
You’re confusing the chicken for the egg.

Sum types are a powerful language feature, but they’re also a general language feature, they don’t exist for the sole purpose of creating a Result type (and indeed a number of languages have had the former and lacked the latter).

Re:Expectations for generics in Go 1.18 by sph on Thursday October 28, 2021 @12:54PM (#29028203)
I still don't get what's wrong with having custom syntax or language facilities to support a feature. Why is that a problem?
Re:Expectations for generics in Go 1.18 by Zababa on Thursday October 28, 2021 @09:35AM (#29025935)
Do you mean that in contrast to affine types, that are here for borrow checking?
Re:Expectations for generics in Go 1.18 by masklinn on Saturday October 30, 2021 @02:40PM (#29051238)
No, I mean that in contrast to the other side of the discussion (zig’s errors).

And affine types are not here for borrow checking, it’s closer to the opposite. Affine types are a formalisation of RAII, borrow checking is a way to make references memory-safe without runtime overhead which mostly avoids unnecessary (and sometimes impossible requiring allocations & refcounting) copies of affine types.