News for hackers. Stuff that matters.
Re:Generics enabled by default in Go tip by erik_seaberg on Saturday August 21, 2021 @06:13AM (#28255728)
I was thinking of generic functions rather than (non-generic) methods on generic types. Unfortunately it looks like reflection can’t look up functions in a module at all, which is surprisingly broken.
Re:Generics enabled by default in Go tip by masklinn on Saturday August 21, 2021 @07:20AM (#28256030)
> Unfortunately it looks like reflection can’t look up functions in a module at all, which is surprisingly broken.

The more time passes the more I think ubiquitous reflection in statically typed languages is what's broken (and a reflection (heh) of deep limitations of the language).

So while I could understand having issues with generics breaking existing reflection code (which doesn't seem to be the case), I'm not going to be sad over reflection having never supported toplevel functions in the first place.

Re:Generics enabled by default in Go tip by erik_seaberg on Saturday August 21, 2021 @08:03AM (#28256292)
What good are top-level functions if they’re unreachable from any script interpreter or management RPC server or other languages’ FFI?
Re:Generics enabled by default in Go tip by masklinn on Saturday August 21, 2021 @10:02AM (#28257093)
I fail to see what any of this has to do with reflection.

> any script interpreter

What are you even talking about.

> or management RPC server

I would very much expect RPC endpoints to be opted in explicitly and statically.

> or other languages’ FFI?

I fail to see why Go-level reflection would be involved in that in any capacity.

> What good are top-level functions

You can call them? From your go code?

Are you saying rust or C can't be because they don't have reflection? That's a strange position.

Re:Generics enabled by default in Go tip by erik_seaberg on Saturday August 21, 2021 @07:29PM (#28261527)
When I type at a Groovy REPL, an interpreter is using reflection for nearly everything. Same goes for native code that has to use reflection via JNI entry points to call Java. It’s damn useful. At the heart of every debugger is a half-finished reflection API that deserves to be cleaned up and surfaced for language interop and novel kinds of tools.
Re:Generics enabled by default in Go tip by pjmlp on Sunday August 22, 2021 @05:46AM (#28264145)
Have a look at D and .NET 5 for compile time reflection.

Or in Java's case annotation processors.

Yes, not everything gets exposed, but it also does the job.

Re:Generics enabled by default in Go tip by 4ad on Saturday August 21, 2021 @08:38AM (#28256484)
Functions are useful because you can call them from your program.