llir / llvm

Library for interacting with LLVM IR in pure Go.
https://llir.github.io/document/
BSD Zero Clause License
1.19k stars 78 forks source link

`interface{}` -> `any` #211

Closed dannypsnl closed 2 years ago

dannypsnl commented 2 years ago

https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb

wow

mewmew commented 2 years ago

Can't say I personally like this change. It hides "ugly" code (i.e. using interface{}) as something that looks nice (i.e. any). Therefore, we are also hiding the fact that such code is really bad Go standard practice and should only be used when no compile-time static type-safe alternative exists. Using interface{} type type assertions may crash at runtime.

dannypsnl commented 2 years ago

So we will do this too one it release?

mewmew commented 2 years ago

So we will do this too one it release?

Do we have any occurrences of the empty interface in the llir/llvm code base?

dannypsnl commented 2 years ago

So we will do this too one it release?

Do we have any occurrences of the empty interface in the llir/llvm code base?

Yes, ir/helper.go

mewmew commented 2 years ago

I see, those have the same API as fmt.Fprintxxx. I don't think using any instead of interface{} gives a benefit, but to stay consistent with the standard library (as they've updated already), we can do so as well.

However, this would make our minimum Go language requirement higher. Is it really needed?

dannypsnl commented 2 years ago

It's not needed, but I don't think minimum requirement would be a problem. From v1 to now, Go ensure the old program is compiled as usual.

mewmew commented 2 years ago

It's not needed, but I don't think minimum requirement would be a problem. From v1 to now, Go ensure the old program is compiled as usual.

Right. As it's not needed, I'll close this issue for now. The very few places were we currently use interface{} are not related to any API that llir/llvm users use, i.e. not related to the IR API. So, the value gained from using any is very little, and the downside is that users with older versions of Go (older than 1.18) would be unable to use the latest commit of llir/llvm.

We currently support back to Go 1.13 it seems:

From go.mod:

go 1.13

So. Closing this issue for now.

Cheers, Robin