Re: [go-nuts] Nil could be the zero value for type variables

2022-06-02 Thread Brian Candler
On Wednesday, 1 June 2022 at 08:49:50 UTC+1 axel.wa...@googlemail.com wrote: > Where confusion might arise is in the operations on nil. It's already >> weird that nil slices and zero-length slices are distinguishable: >> https://go.dev/play/p/6MVECg4onAk >> >> We'd then end up in the same positi

Re: [go-nuts] Nil could be the zero value for type variables

2022-06-02 Thread 'Axel Wagner' via golang-nuts
This is increasingly off-topic (I don't have anything to add to the on-topic stuff itself), but. On Thu, Jun 2, 2022 at 11:03 AM Brian Candler wrote: > I wonder then why slice wasn't defined the same way - i.e. the zero value > of a slice could have been "empty slice". Today, empty slice and nil

[go-nuts] How to call function from struct in slice?

2022-06-02 Thread Jay
In a code example, I’m confuse if it’s possible to call ModuleName() each package API after execute CompileModules()? app.go func CompileModules() []interface{ return []interface{ Example1.AddModule(), Example2.AddModule(), Example3.AddModule(), } }

[go-nuts] How to call Name() from slice?

2022-06-02 Thread Jay
In a code example, I’m confuse if it’s possible to call ModuleName() each package API after execute CompileModules()? app.go func CompileModules() []interface{ return []interface{ Example1.AddModule(), Example2.AddModule(), Example3.AddModule(), } }

[go-nuts] Re: syscall/js: wasm perf question

2022-06-02 Thread atd...@gmail.com
Really weird, for a same TODOMVC react app, Chrome (101.0.4951.64) seems to be faster than Firefox (77.0.1) at handling a same DOM event (~12ms vs ~30ms). But with my implementation of the same TODOMVC app in wasm, built with Go, the same event is handled much faster in Firefox than in Chrome (

Re: [go-nuts] LockOSThread, switching (Linux kernel) namespaces: what happens to the main thread...?

2022-06-02 Thread TheDiveO
Hi Ian, On Thursday, June 2, 2022 at 3:03:17 AM UTC+2 Ian Lance Taylor wrote: > On Wed, Jun 1, 2022 at 10:45 AM TheDiveO wrote: > > What now? Terminating T0 doesn't look like a great idea at second look: > for instance, as I mentioned above, this causes some problems further down > the road, s

[go-nuts] Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread Deividas Petraitis
Background: when I am writing code mostly I end up with some clunky solutions I am not happy with and one of the reasons I think is that I might be mixing funcs vs methods. So the question is basically the title. I have searched both in this group ( without a luck ) and in the Internet for po

Re: [go-nuts] Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread 'Axel Wagner' via golang-nuts
On Thu, Jun 2, 2022 at 4:38 PM Deividas Petraitis wrote: > 1. Structs are for representing things, they are things > 2. Funcs are for performing actions, calculating things > 3. Methods for performing actions on thing state > 4. Methods to satisfy interface > 4 is really the *big* technical poin

Re: [go-nuts] Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread Jan Mercl
On Thu, Jun 2, 2022 at 4:38 PM Deividas Petraitis wrote: > 1. Structs are for representing things, they are things Forget about structs. Methods are attached to types. Structs are just one of the many kinds of types. Assuming structs only does not provide the full picture one needs to think abou

Re: [go-nuts] LockOSThread, switching (Linux kernel) namespaces: what happens to the main thread...?

2022-06-02 Thread Ian Lance Taylor
On Thu, Jun 2, 2022 at 6:20 AM TheDiveO wrote: > > On Thursday, June 2, 2022 at 3:03:17 AM UTC+2 Ian Lance Taylor wrote: >> >> On Wed, Jun 1, 2022 at 10:45 AM TheDiveO wrote: >> > What now? Terminating T0 doesn't look like a great idea at second look: >> > for instance, as I mentioned above, this

Re: [go-nuts] LockOSThread, switching (Linux kernel) namespaces: what happens to the main thread...?

2022-06-02 Thread TheDiveO
Hi Ian, On Thursday, June 2, 2022 at 5:48:18 PM UTC+2 Ian Lance Taylor wrote: > Can you point to any documentation about the problem. Earlier you > mentioned that there was something in the procfs man page. I didn't > see it, but as the procfs man page is very large I'm sure I just > missed i

Re: [go-nuts] LockOSThread, switching (Linux kernel) namespaces: what happens to the main thread...?

2022-06-02 Thread Ian Lance Taylor
On Thu, Jun 2, 2022 at 9:21 AM TheDiveO wrote: > > On Thursday, June 2, 2022 at 5:48:18 PM UTC+2 Ian Lance Taylor wrote: >> >> Can you point to any documentation about the problem. Earlier you >> mentioned that there was something in the procfs man page. I didn't >> see it, but as the procfs man p

Re: [go-nuts] Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread Jesper Louis Andersen
On Thu, Jun 2, 2022 at 4:38 PM Deividas Petraitis wrote: > Background: when I am writing code mostly I end up with some clunky > solutions I am not happy with and one of the reasons I think is that I > might be mixing funcs vs methods. > > Squint your eyes enough, and methods are just a special k

Re: [go-nuts] Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread 'Sean Liao' via golang-nuts
Namespacing, aesthetics, and interfaces If, for whatever reason, you don't like the way method calls look, you can use: var a net.TCPAddr _ = a.Family() // usual method call _ = net.TCPAddr.Family(&a) // equivalent to above If everything was a pure function, it'd look much like the se

[go-nuts] Re: Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread atd...@gmail.com
A short way to see it for me is to reason in terms of capabilities. What is an instance of a given type supposed to be able to do? (method) versus what am I able to do with or upon a given instance (function). It's not always clear though but it can help. On Thursday, June 2, 2022 at 4:38:37 PM U

Re: [go-nuts] LockOSThread, switching (Linux kernel) namespaces: what happens to the main thread...?

2022-06-02 Thread TheDiveO
I've created https://github.com/golang/go/issues/53210 and the answer is already in! The initial thread m0 is actually handled differently in that it doesn't get terminated but, to use the runtime terminology, "wedged". Now this explains what I'm seeing in production, because by some chance m0

[go-nuts] Re: Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread Deividas Petraitis
I am really happy with thoughts and points shared so far, thank you all! Unfortunately I am not able to edit original my post, so to make sure I got all of these points I will just sum up everything below, I think this summary may be valuable for any less experienced gopher, please correct me