Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2021-11-07 Thread Jan Mercl
On Sun, Nov 7, 2021 at 7:23 PM Kamil Ziemian wrote: > Can anyone give me explicit example when semicolon is omitted in accordance > to the second rule and explanation where it should be? I probably see such > situations dozens of times, I just not know that they would needed semicolon > in som

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2021-11-07 Thread Kamil Ziemian
Hello, I go back to reading Go spec and I read about omitting semicolon in Go code. I know from some Rob Pike talks on YT or similar source, that compiler inserts semicolon in "places where C programmer would expected it to write". And since I try to follow Go style of writing code (Emacs also

Re: [go-nuts] Limits of type parameter inference in function calls

2021-11-07 Thread Florian Weimer
* Axel Wagner: > One way to fix this is to change the signatures to > > func Contains[I Iterator[T], T comparable](c I, value T) bool > func Contains2[I Iterator[T], T comparable](value T, c I) bool I had not realized that, thanks. The opposite order is perhaps more useful, [T comparable, I Itera

Re: [go-nuts] Limits of type parameter inference in function calls

2021-11-07 Thread 'Axel Wagner' via golang-nuts
One way to fix this is to change the signatures to func Contains[I Iterator[T], T comparable](c I, value T) bool func Contains2[I Iterator[T], T comparable](value T, c I) bool Though I tend to agree that it would be preferable for this inference to work. On Sun, Nov 7, 2021 at 11:52 AM Florian W

[go-nuts] Limits of type parameter inference in function calls

2021-11-07 Thread Florian Weimer
I've tried this example, related to the collections example in the proposal. package main type Iterator[T any] interface{ Next() (T, bool) } func Contains[T comparable](c Iterator[T], value T) bool { for { v, ok := c.Next() if ok {