[go-nuts] Re: Short Variable Declarations Are Oversold

2023-04-23 Thread tapi...@gmail.com
Type inference is not the main purpose (or even the purpose) of short declarations. I do agree that the negative impact of short declarations is larger than its positive impact, for reasons different from the one you described. Some reasons: * short declarations causes confusions (esp, for new g

Re: [go-nuts] Why is there no pure StableSort in golang.org/x/exp/slices?

2023-04-23 Thread Uli Kunitz
I have written the code now and run a benchmark. In the benchmark function slices.Sort is 9% faster than slices.SortFunc, which is ca. 9% faster than slices.SortStableFunc for my benchmark. I don't need stable sort, but assumed that merge sorting would benefit more from presorted runs. On Sunda

Re: [go-nuts] ¿ Where is the source code of atomic.AddInt32?

2023-04-23 Thread Eli Lindsey
Hi Victor, This shows that the code you linked is a shim over runtime/internal/atomic: https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/sync/atomic/asm.s;l=40 In runtime/internal/atomic you’ll find asm implementations specific to the various supported architectures. For example, here

Re: [go-nuts] ¿ Where is the source code of atomic.AddInt32?

2023-04-23 Thread Ian Lance Taylor
On Sun, Apr 23, 2023 at 12:23 PM Victor Giordano wrote: > Hi there! > > Hope you are having a great weekend (This is actually friendly greeting > and you may greet me as well, it will be more than welcome) > > I reach this line >

[go-nuts] ¿ Where is the source code of atomic.AddInt32?

2023-04-23 Thread Victor Giordano
Hi there! Hope you are having a great weekend (This is actually friendly greeting and you may greet me as well, it will be more than welcome) I reach this line and that is folks! [image: That's All Folks!

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread Robert Engels
I wouldn’t have don’t it that way. I would have made := mean all variables must be new. And = mean any new variable requires a decoration. So in this case, var x,err = means x is new and err is reused. The variable clauses are segregated by a , > On Apr 23, 2023, at 9:07 AM, Axel Wagner

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread 'Axel Wagner' via golang-nuts
On Sun, Apr 23, 2023 at 4:01 PM Robert Engels wrote: > Personally that syntax has always bothered me with readability. It > requires lots of previous knowledge in some cases. A syntax like > > x, var y int = blah > > Is more explicit that x is reused and y is declared. > That specific suggestion

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread Robert Engels
To clarify, the semantics of a go statement from a language perspective changes based on earlier statements. That is simply weird - and hurts readability. > On Apr 23, 2023, at 9:01 AM, Robert Engels wrote: > >  > Personally that syntax has always bothered me with readability. It requires >

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread Robert Engels
Personally that syntax has always bothered me with readability. It requires lots of previous knowledge in some cases. A syntax like x, var y int = blah Is more explicit that x is reused and y is declared. Go is all about being explicit until it isn’t. > On Apr 23, 2023, at 8:28 AM, 'Axel W

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread 'Axel Wagner' via golang-nuts
Just to nit-pick everyone: Short variable declarations are not there to omit type information. You can do that with a regular variable declaration: https://go.dev/play/p/6XePFCh-6G2 Short variable declarations exist to 1. be shorter and 2. allow you to avoid re-declaration errors when assigning mul

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread Jesper Louis Andersen
On Sun, Apr 23, 2023 at 12:31 AM jlfo...@berkeley.edu < jlforr...@berkeley.edu> wrote: > > Short definitions detract from one of Go’s primary goals - readability. I > started using Go in the first place because I wanted a strongly typed > language with explicit type declarations. > > Your claim of

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread Shulhan
23 Apr 2023 05:31:25 jlfo...@berkeley.edu : > Short definitions detract from one of Go’s primary goals - readability. I > started using Go in the first place because I wanted a strongly typed > language with explicit type declarations.  > > As a result of all this, I’ve started to avoid short

Re: [go-nuts] Re: Home directory?

2023-04-23 Thread Amnon
Ok Jan, you are right. They do still play a part under the hood. So external modules get cached under $GOMODCACHE which is $GOPATH/pkg/mod by default and go install installs executables under $GOBIN which is $GOPATH/bin by default. But my point is that (apart from $GOBIN), this is something that

Re: [go-nuts] Re: Home directory?

2023-04-23 Thread Jan Mercl
On Sun, Apr 23, 2023 at 10:28 AM Amnon wrote: > Yes GOPATH and GOROOT have been deprecated. Both are alive and well. They are essential for the build system/go command to work as required. tl;dr: There's a default value of GOPATH so one does not have to set it. A much longer version can be obta

[go-nuts] Re: Home directory?

2023-04-23 Thread Amnon
I looked at https://go.dev/doc/tutorial/create-module it only has two mentions of, which are just suggestions regarding where to create your working directory. But it is just a suggestion, and you can choose any location which is convenient for you. Yes GOPATH and GOROOT have been deprecated.

[go-nuts] Home directory?

2023-04-23 Thread joseph.p...@gmail.com
In the ‘Create a Go Module’ documentation, it keeps referencing ‘home directory’ and uses the unix command ‘cd’. Do they literally mean my unix home directory or do they mean my GOPATH directory? Have GOPATH and GOROOT been deprecated? Thanks, Hoe -- You received this message because you ar