Re: [go-nuts] fstest.MapFS ReadDir does not set name field for entry.Name()

2022-04-02 Thread Ian Lance Taylor
On Sat, Apr 2, 2022 at 2:46 PM Kalen Krempely wrote: > > 2) As a follow up question I find it weird that VerifyDir needs to take in > both a filesystem and the root path. (ie: `VerifyDir(fsys fs.FS, dir > string)`) That is, the calling code will be something like > VerifyDir(os.DirFS("/some/pat

Re: [go-nuts] Tacit Golang?

2022-04-02 Thread Bakul Shah
If I understand you right, you seem to want to use "<-" as the "compose" higher order function but as an infix operator. That is, instead of "value := F(G(args...))", you want to be able to write "value := (F <- G)(args...)". Further, "F <- G <- H" means "F <- (G <- H)". F, G &H are functions su

Re: [go-nuts] fstest.MapFS ReadDir does not set name field for entry.Name()

2022-04-02 Thread Kalen Krempely
Thanks Ian for the reply! *1)* I think I figured out what was going on. Basically, I need to pass the root path to my verifyDir function and just have the fstest.MapFS contain the sub elements, rather than the full paths. That is, the example test code needs to be: t.Run("some test", func(t *te

Re: [go-nuts] Re: Tacit Golang?

2022-04-02 Thread Sam Hughes
Yep. That’s the status quo. My tongue-in-cheek response to that as objection is “If simply sufficient utility for a given task were valid as objection to a new utility, why Go over C?” If you’re not posing that as objection, no need to dwell on it. Yeah. That’s exactly the kind of behavior I want

[go-nuts] Alternative generics design with some interesting aspects

2022-04-02 Thread will....@gmail.com
Hey all, Congrats to the Go Team for shipping generics! I was experimenting with a design for generics for a long time. I thought I'd share it anyway for fun. I think it has some interesting (IMHO) aspects and trade-offs compared to the design that shipped: - Type variable declarations are

Re: [go-nuts] Are the two constraints equivalent to each other?

2022-04-02 Thread tapi...@gmail.com
Ah, I forgot that point. Thanks for the explanation! On Saturday, April 2, 2022 at 10:00:27 PM UTC+8 axel.wa...@googlemail.com wrote: > Ptr[int] is a defined type, `*int` is not. So the two types are not the > same and this is working as intended. > > On Sat, Apr 2, 2022 at 3:50 PM tapi...@gmai

Re: [go-nuts] Are the two constraints equivalent to each other?

2022-04-02 Thread 'Axel Wagner' via golang-nuts
Ptr[int] is a defined type, `*int` is not. So the two types are not the same and this is working as intended. On Sat, Apr 2, 2022 at 3:50 PM tapi...@gmail.com wrote: > > package main > > type Ptr[E any] *E > > type MyConstraint interface { > Ptr[int] > } > > type YourConstraint interface { >

[go-nuts] Are the two constraints equivalent to each other?

2022-04-02 Thread tapi...@gmail.com
package main type Ptr[E any] *E type MyConstraint interface { Ptr[int] } type YourConstraint interface { *int } func foo[T MyConstraint](x T) { } func bar[T YourConstraint](x T) { } func main() { var x = new(int) foo(x) // *int does not implement MyConstraint bar(x) } --

Re: [go-nuts] Why is it forbidden to add methods to an existing type?

2022-04-02 Thread Brian Candler
Correct repository path is: https://github.com/jackc/pgtype Interesting. These structs generally contain a Status value as well: type Int8 struct { Int int64 Status Status } where pgtype.go has: type Status byte const ( Undefined Status = iota Null Present ) They also have Set