Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread Robert Engels
I think you have to go a bit more and use a RW mutex to ensure memory consistency (for the simple solution). > On Jan 5, 2021, at 8:52 PM, joseph.p...@gmail.com > wrote: > > Well, I think I only need to lock on writes, and it'll be easier if I just > lock the entire tree on writes. Reads wi

Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread joseph.p...@gmail.com
Well, I think I only need to lock on writes, and it'll be easier if I just lock the entire tree on writes. Reads will be the majority of the operations by far. This is for a bit of caching before we go to a K/V database like REDIS, etc. On Tuesday, January 5, 2021 at 5:16:36 PM UTC-8 k.alex...@

Re: [go-nuts] Unsupported File Format error while building for linux-amd64 on mac os

2021-01-05 Thread Matt Joiner
I found this, which worked without GOPATH assumptions: https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/ On Monday, 1 October 2018 at 7:32:23 pm UTC+10 Ankit Gupta wrote: > Tamas, > > I installed docker on mac and cross compiled using xgo like you suggested. > Worked per

Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread K. Alex Mills
On Tue, Jan 5, 2021, 6:59 PM Nathan Fisher wrote: > Does write only locking provide read correctness? I would’ve thought based > on the memory model it could cause issues? > > https://golang.org/ref/mem#tmp_2 > It depends on your notion of "read correctness", specifically when you consider each

Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread Nathan Fisher
Does write only locking provide read correctness? I would’ve thought based on the memory model it could cause issues? https://golang.org/ref/mem#tmp_2 On Tue, Jan 5, 2021 at 19:40, K. Alex Mills wrote: > That is the simplest and most conservative way go about it, but ultimately > it depends on

Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread K. Alex Mills
That is the simplest and most conservative way go about it, but ultimately it depends on what you need out of your concurrency semantics. If you're willing to settle for a linearizable execution, you can gain some performance improvements by only checking the lock for write operations. So long as

[go-nuts] Thread safe tree library?

2021-01-05 Thread joseph.p...@gmail.com
Is there a simple tree library that is thread safe? If I have to write one for myself, do I have to set locks on nodes as I walk the tree to prevent another thread from changing nodes that are 'above' me? -- You received this message because you are subscribed to the Google Groups "golang-nu

Re: [go-nuts] Generics and constraints question

2021-01-05 Thread Brian Candler
On Tuesday, 5 January 2021 at 20:27:57 UTC rog wrote: > You can do this with type-list interfaces: > https://go2goplay.golang.org/p/wfHnVHOMcyK > > This is one of the harder parts of the proposal to understand IMHO, but > perhaps it will become easier with familiarity. > Thank you! -- You re

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread 'Axel Wagner' via golang-nuts
On Tue, Jan 5, 2021 at 7:25 PM tapi...@gmail.com wrote: > On Tuesday, January 5, 2021 at 8:43:44 AM UTC-5 axel.wa...@googlemail.com > wrote: > >> On Tue, Jan 5, 2021 at 12:03 PM Anonymous AWK fan >> wrote: >> >>> Why does there need to be a delimiter, there isn't one between chan and >>> int in

[go-nuts] an open source project to replace SMTP/email

2021-01-05 Thread Liam
The mnm project is building a legitimate email replacement: a client[1], a server[2], and a simple protocol[3] between them. (Legitimate, i.e. n-identity, decentralized, store-and-forward, open protocol, open source.) https://mnmnotmail.org https://twitter.com/mnmnotmail Both client and server

Re: [go-nuts] Generics and formatting

2021-01-05 Thread Ian Lance Taylor
On Tue, Jan 5, 2021 at 8:11 AM Brian Candler wrote: > > I don't know if this is expected, but this (bad) program causes the go2go > playground to give "panic: assertion failed" > > https://go2goplay.golang.org/p/VH5SLJNxw3X > > - I think it's the compiler itself that's panicing, not the runtime (

Re: [go-nuts] Generics and constraints question

2021-01-05 Thread Ian Lance Taylor
This definitely needs a better error message. Ian On Tue, Jan 5, 2021 at 12:27 PM roger peppe wrote: > > You can do this with type-list interfaces: > https://go2goplay.golang.org/p/wfHnVHOMcyK > > This is one of the harder parts of the proposal to understand IMHO, but > perhaps it will become

Re: [go-nuts] Generics and constraints question

2021-01-05 Thread roger peppe
You can do this with type-list interfaces: https://go2goplay.golang.org/p/wfHnVHOMcyK This is one of the harder parts of the proposal to understand IMHO, but perhaps it will become easier with familiarity. On Tue, 5 Jan 2021, 17:32 Brian Candler, wrote: > Question: how to make a generic functio

[go-nuts] Question about "go get", modules and indirect dependencies

2021-01-05 Thread Orson Cart
Apologies if this is a dumb question as I don't have a great deal of experience with modules. So, if I use the "go get" command to download a module, when I look in the module cache the @v directory of the requested module contains at least one .info file. This isn't the case for any indirect d

Re: [go-nuts] Generics and formatting

2021-01-05 Thread Brian Candler
Here's another unhelpful error: https://go2goplay.golang.org/p/GDxiXiIIti7 Error: "prog.go2:7:11: all type parameters must be named" Actual problem: the type parameters *were* named, but no constraint was given. func blah[T1, T2](x T1) T2 { // wrong func blah[T1, T2 any](x T1) T2 { // fixed

[go-nuts] Re: [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread Brian Candler
On Tuesday, 5 January 2021 at 18:17:14 UTC tapi...@gmail.com wrote: > What about if the custom generic function syntax is consistent with built > ones? > For example: > > v := MakeMyMap(mymap[T1]T2) > Would this be mandatory for all generics which take two or more types? It seems unbalanc

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread tapi...@gmail.com
On Tuesday, January 5, 2021 at 8:43:44 AM UTC-5 axel.wa...@googlemail.com wrote: > On Tue, Jan 5, 2021 at 12:03 PM Anonymous AWK fan > wrote: > >> Why does there need to be a delimiter, there isn't one between chan and >> int in chan int, which I think is more readable than chan[int]. >> > >

[go-nuts] Re: [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread tapi...@gmail.com
On Tuesday, January 5, 2021 at 11:31:44 AM UTC-5 Brian Candler wrote: > Are you trying to make user-defined generic maps look more like built-in > ones? > > map[T1]T2 is hard-coded syntax in go. But so is m[k] for accessing > elements - and you can't use that in user-defined types anyway. > >

[go-nuts] Generics and constraints question

2021-01-05 Thread Brian Candler
Question: how to make a generic function which takes a type T where the constraint is "*T satisfies a given interface"? func (m *MyMap[KT, VT]) init() { m.data = make(map[KT]VT) } type Initializer interface { init() } func mynew[T Initializer]() *T { t := new(T) t.init() return t } /*

[go-nuts] Re: [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread Brian Candler
Are you trying to make user-defined generic maps look more like built-in ones? map[T1]T2 is hard-coded syntax in go. But so is m[k] for accessing elements - and you can't use that in user-defined types anyway. Therefore I don't think it helps much to be able to write mymap[T1]T2 instead of my

Re: [go-nuts] Generics and formatting

2021-01-05 Thread Brian Candler
I don't know if this is expected, but this (bad) program causes the go2go playground to give "panic: assertion failed" https://go2goplay.golang.org/p/VH5SLJNxw3X - I think it's the compiler itself that's panicing, not the runtime (since it doesn't get as far as the next line). Aside: my

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread 'Axel Wagner' via golang-nuts
On Tue, Jan 5, 2021 at 12:03 PM Anonymous AWK fan wrote: > Why does there need to be a delimiter, there isn't one between chan and > int in chan int, which I think is more readable than chan[int]. > `chan` is a keyword, names of generic types and functions are identifiers. So, in a way, yes, the

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread Levieux Michel
There is a delimiter in 'chan int' -> ' ' (space) I don't think it is a good assumption that "most generic types would only have 1 type-parameter" (or 2, or 3, or any other arbitrary number for what it's worth). Moreover, I don't think it is a good idea to assimilate builtin language constructs to

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread 'Anonymous AWK fan' via golang-nuts
Axel, please send your reply to golang-nuts too, you can ignore the rest of this, I already sent it to you but not golang-nuts because I didn't reply to all. > What is the "them" to be omitted if there is only one type parameter? It > wouldn't make sense to omit the brackets (because there need

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread tapi...@gmail.com
On Monday, January 4, 2021 at 5:23:06 PM UTC-5 ren...@ix.netcom.com wrote: > Reading > > sync.Map[string]linked.List string > > I have no idea what that represents? > If you can read sync.Map[string]chan string then you can read "sync.Map[string]linked.List string" too. > > What if