News for hackers. Stuff that matters.
Re:Golang: How to Update APIs for Generics by qaq on Thursday September 16, 2021 @02:30AM (#28548730)
Can't wait for the thing to land. My only remaining wish is sum types
Re:Golang: How to Update APIs for Generics by zerr on Thursday September 16, 2021 @06:29AM (#28549994)
Any updates regarding the if-hell of error handling?
Re:Golang: How to Update APIs for Generics by mseepgood on Thursday September 16, 2021 @06:52AM (#28550131)
They spent months consolidating feedback and made two proposals. The community didn't want change. Now they are no longer working on it and are focusing on getting generics out.
Re:Golang: How to Update APIs for Generics by _ph_ on Thursday September 16, 2021 @07:09AM (#28550244)
I would guess they start looking into it again after the generics transition is done. But I think it is a good practice not to force things but let certain ideas rest, if no agreement can be reached. Probably the best solution hasn't been found yet :)
Re:Golang: How to Update APIs for Generics by neetle on Thursday September 16, 2021 @06:34AM (#28550022)
"Try another language instead" is always a valid option.

There isn't anything wrong with a language just not jiving with your sensibilities.

Re:Golang: How to Update APIs for Generics by chakkepolja on Thursday September 16, 2021 @10:24AM (#28552219)
Problem is, perfect language with perfect libraries and perfect tools doesn't exist.
Re:Golang: How to Update APIs for Generics by lamontcg on Thursday September 16, 2021 @12:29PM (#28553823)
Somewhere in the middle of Go, Julia and Rust is the programming language I'd really like to use.
Re:Golang: How to Update APIs for Generics by qaq on Thursday September 16, 2021 @04:39PM (#28557241)
I'd throw in Swift into the mix
Re:Golang: How to Update APIs for Generics by lamontcg on Wednesday September 22, 2021 @02:23AM (#28613602)
I just took another fresh look at it and on the surface the syntax looks really attractive.
Re:Golang: How to Update APIs for Generics by cy_hauser on Thursday September 16, 2021 @09:31PM (#28560095)
No, it's not. It's just being dismissive because your wants are being met by the current state.
Re:Golang: How to Update APIs for Generics by _6pvr on Thursday September 16, 2021 @11:42AM (#28553244)
(Not attacking you) Do you write a substantial amount of Go very frequently?
Re:Golang: How to Update APIs for Generics by yutijke on Thursday September 16, 2021 @05:59AM (#28549815)
I have never used golang but from my reading of the type parameters proposal, it also includes an approximation of "Sum types".

You can define an interface with a closed set of types

type Number interface { float64, int64, ... }

Now, the value will be boxed, so you will not have no-allocation sum types but you can approximate boxed sum types with this I think.

Re:Golang: How to Update APIs for Generics by cube2222 on Thursday September 16, 2021 @10:40AM (#28552415)
Approximating closed sum types is easy already, by creating an interface with a stub private method and implementing it for all variants. Then it's not possible to implement it using a type outside of that package.

The main thing that's lacking is compile time checks whether variant matching is exhaustive.

Re:Golang: How to Update APIs for Generics by rawoke083600 on Thursday September 16, 2021 @04:27AM (#28549357)
THIS ! and "pattern-matching" :)
Re:Golang: How to Update APIs for Generics by a-saleh on Thursday September 16, 2021 @05:13AM (#28549583)
So, in the end all of languages move closer to StandardML :D Like even python has sum-types and pattern matching now!
Re:Golang: How to Update APIs for Generics by rawoke083600 on Thursday September 16, 2021 @06:03AM (#28549835)
Lol I know I know... but it is so useful :)
Re:Golang: How to Update APIs for Generics by xmorse on Thursday September 16, 2021 @05:38AM (#28549701)
That would be awesome!
Re:Golang: How to Update APIs for Generics by tonyedgecombe on Thursday September 16, 2021 @06:07AM (#28549855)
And exceptions :)
Re:Golang: How to Update APIs for Generics by szastamasta on Thursday September 16, 2021 @06:46AM (#28550094)
Please, just not exceptions.
Re:Golang: How to Update APIs for Generics by mseepgood on Thursday September 16, 2021 @07:10AM (#28550250)
Too late, Go already has exceptions since 1.0.
Re:Golang: How to Update APIs for Generics by pjmlp on Thursday September 16, 2021 @07:36AM (#28550420)
Indeeed,

    func ThrowIfError(err error) {
        if err != nil {
            panic(err)
        }
    }
    // ....
    name, err := FuncWithError()
    ThrowIfError(err)
Re:Golang: How to Update APIs for Generics by mseepgood on Thursday September 16, 2021 @07:08AM (#28550236)
Panic and recover already exist, which are semantically exceptions.
Re:Golang: How to Update APIs for Generics by k_bx on Thursday September 16, 2021 @05:36AM (#28549688)
Were there discussions? What is the general impression, is there hope?