Re: [go-nuts] Why is only "if", but not "for" and "switch", allowed to follow "else" keyword?

2020-10-06 Thread tapi...@gmail.com
On Tuesday, October 6, 2020 at 1:54:16 PM UTC-4 Ian Lance Taylor wrote: > On Tue, Oct 6, 2020 at 10:28 AM tapi...@gmail.com > wrote: > > > > IMO, the bar function is cleaner and more readable than the foo > function. > > How do you think? > > > > func foo() { > > if vs := f(); len(vs)

Re: [go-nuts] Why is only "if", but not "for" and "switch", allowed to follow "else" keyword?

2020-10-06 Thread Ian Lance Taylor
On Tue, Oct 6, 2020 at 10:28 AM tapi...@gmail.com wrote: > > IMO, the bar function is cleaner and more readable than the foo function. > How do you think? > > func foo() { > if vs := f(); len(vs) == 0 { > } else { > for _, v := range vs { > } >

Re: [go-nuts] Question on the generics proposal and arrays

2020-10-06 Thread Ian Lance Taylor
On Tue, Oct 6, 2020 at 6:32 AM Markus Heukelom wrote: > > It appears to me the current proposal does not allow you to write a function > that sorts an array of any size: > > func SortArray[T comparable](array [??]T, less func(a, b T) bool) [??]T {} > > Is it correct that this is not possible? Or

Re: [go-nuts] Why is only "if", but not "for" and "switch", allowed to follow "else" keyword?

2020-10-06 Thread Jan Mercl
IMO opinion the answer is nicely demonstrated in the alignment of sone of the closing braces you've chosen in the func bar example. On Tue, Oct 6, 2020, 19:28 tapi...@gmail.com wrote: > IMO, the bar function is cleaner and more readable than the foo function. > How do you think? > > func

[go-nuts] Why is only "if", but not "for" and "switch", allowed to follow "else" keyword?

2020-10-06 Thread tapi...@gmail.com
IMO, the bar function is cleaner and more readable than the foo function. How do you think? func foo() { if vs := f(); len(vs) == 0 { } else { for _, v := range vs { } } if vs := f(); len(vs) == 0 { } else {

[go-nuts] Re: Question on the generics proposal and arrays

2020-10-06 Thread Viktor Kojouharov
This would require something similar to rust's const generics. IIRC, that's not on the table with the initial draft On Tuesday, October 6, 2020 at 3:31:46 PM UTC+2 markus@gain.pro wrote: > It appears to me the current proposal does not allow you to write a > function that sorts an array of

[go-nuts] [ANN] Type-safe database client for Postgres, MySQL & SQLite

2020-10-06 Thread Luca Steeb
Hey Gophers, I’d like to share our new auto-generated database client for Go – it’s focused on complete type-safety wherever possible and makes querying for complex data and relations a delight :) I’m currently experimenting with syntax and features, so any feedback would be highly

Re: [go-nuts] Re: Proposal to add Index operator methods

2020-10-06 Thread Raanan Hadar
A transpiler that will implement index operator methods will be very appealing at first. But it won't be long before general operator overloading will be added to its feature set and the result is splitting Go to a different language... The question is, what is best to the go community in the

Re: [go-nuts] Re: Proposal to add Index operator methods

2020-10-06 Thread Wojciech S. Czarnecki
Dnia 2020-10-06, o godz. 00:56:38 Raanan Hadar napisał(a): > To a gonum user, this proposal is about a 20% improvement and nothing to run > home about. > To a matlab/python programmer, this solves about 80% of their problems and > combining this > with the other benefits of Go is enough to

[go-nuts] Question on the generics proposal and arrays

2020-10-06 Thread Markus Heukelom
It appears to me the current proposal does not allow you to write a function that sorts an array of any size: func SortArray[T comparable](array [??]T, less func(a, b T) bool) [??]T {} Is it correct that this is not possible? Or is this expressed differently? To clarify, I am seeking for

Re: [go-nuts] Re: Proper way of mocking interfaces in unit tests - the golang way

2020-10-06 Thread Jesper Louis Andersen
On Mon, Oct 5, 2020 at 3:03 PM 'Bryan C. Mills' via golang-nuts < golang-nuts@googlegroups.com> wrote: > > The core of the problem is that `assert` functions generally *cannot* provide > enough context to produce useful test failures >

Re: [go-nuts] Re: Proposal to add Index operator methods

2020-10-06 Thread Raanan Hadar
Lets start with saying that I think this is a valid criticism. Although it does not solve things 100%, it does solve the heart of the problem for me at least: There is a mixture of index operators with functional operators in the syntax: The [] operator gives the reader the 'where' context

Re: [go-nuts] Re: Proposal to add Index operator methods

2020-10-06 Thread Jon Reiter
i think this looks nice but realistically only cleans up v simple cases. a lot of the very-verbose-and-not-so-elegant-looking multidimensional math stuff looks "worse" than other languages because go doesn't have operator overloading. it is not clear to me this improves syntax too much in