Re: [go-nuts] Generics Draft: Mixing types and methods.

2019-08-02 Thread Steven Blenkinsop
On Fri, Aug 2, 2019 at 6:55 PM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > > contract Comparable(T) { > T comparable, Equal(T) bool > } > Wait, does this work? I mean, `comparable` is a contract, but it's being used as a constraint. Could you also write: contract

Re: [go-nuts] Generics Draft: Mixing types and methods.

2019-08-02 Thread Robert Engels
Clear as mud. > On Aug 2, 2019, at 6:03 PM, 'Axel Wagner' via golang-nuts > wrote: > > Just tried running it through the prototype type-checker and one correction: > You also have to convert `a` and `` to interface{}, so that you are allowed > to type-assert on them: > if e, ok :=

Re: [go-nuts] Generics Draft: Mixing types and methods.

2019-08-02 Thread 'Axel Wagner' via golang-nuts
Just tried running it through the prototype type-checker and one correction: You also have to convert `a` and `` to interface{}, so that you are allowed to type-assert on them: if e, ok := (interface{}(a)).(equaler(T)); ok { return e.Eq(b) } if e, ok := (interface{}()).(equaler(T)); ok {

Re: [go-nuts] Generics Draft: Mixing types and methods.

2019-08-02 Thread 'Axel Wagner' via golang-nuts
FWIW: interface{}(a) == interface{}(b) would work. It would panic if a and b have the same, non-comparable type. But if you know the type is equal and comparable, it's well-defined and does what you want. So you have to modify your code a bit: type equaler(type T) interface { Equal(T) bool }

Re: [go-nuts] Generics Draft: Mixing types and methods.

2019-08-02 Thread Bruno Albuquerque
Ok, it makes sense. I do think that supporting something like this might make the proposal even more appealing as it will bring custom types somewhat closer to builtin types by allowing generic functions/methods that can act on both at the same time. On Fri, Aug 2, 2019 at 1:28 PM Ian Lance

Re: [go-nuts] Generics Draft: Mixing types and methods.

2019-08-02 Thread Ian Lance Taylor
On Fri, Aug 2, 2019 at 1:12 PM Bruno Albuquerque wrote: > > I was thinking about a way to "extend" usual operations (say, equality > checks) to types that can not be compared the usual way (they are not > "comparable" in the contract sense) and came up with something like this: > > // Just to

[go-nuts] Generics Draft: Mixing types and methods.

2019-08-02 Thread Bruno Albuquerque
I was thinking about a way to "extend" usual operations (say, equality checks) to types that can not be compared the usual way (they are not "comparable" in the contract sense) and came up with something like this: // Just to use for type assertion later. type Equaler interface {

[go-nuts] Go tool capable of hiding any file within an image.

2019-08-02 Thread Dimitar Petrov
stegify is a simple command line tool capable of fully transparent hiding any file within an image. You can give it a look it works pretty fine and is useful for some personal secrets :) (https://github.com/DimitarPetrov/stegify) -- You received

[go-nuts] Repo with multiple modules and vendoring in main module: how to avoid constant re-vendoring?

2019-08-02 Thread julius . volz
Hi, I'm exploring splitting up the main Prometheus repo ( https://github.com/prometheus/prometheus) into a main module and several library modules. We'd like to avoid having to update versions in the main module's go.mod for any change to a local module, which I can already solve with

[go-nuts] [gollvm] build failure (mangled name of 'prefetch' inconsistent between llvm and gollvm)

2019-08-02 Thread Xiangdong JI
Hello, I got a build failures after syncing llvm, gollvm and gofront-end to their latest commits, llvm-goc errors out: = Intrinsic name not mangled correctly for type arguments! Should be: llvm.prefetch.p0i8 void (i8*, i32, i32,