golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
121.45k stars 17.4k forks source link

proposal: Go 2: change chan syntax from <- to "in out" #39454

Closed dmitryuck closed 4 years ago

dmitryuck commented 4 years ago

Would you consider yourself a novice, intermediate, or experienced Go programmer?

// write data to the channel "Hello world" in c

// read data from channel var data := out c

// read-only channel var c out chan int

func do(c in chan string) {}

Or add "->" operator

// write data to the channel "Hello world" -> c

// read data from channel var data := <- c

What would change in the language spec? Please also describe the change informally, as in a class teaching Go.

// before var c chan string c <- "Hello world"

var data := <- c

// after var c chan string "Hello world" -> c

// or "Hello world" in c

var data := out c

What is the cost of this proposal? (Every language change has a cost).

mvdan commented 4 years ago

Please note that you should fill https://github.com/golang/proposal/blob/master/go2-language-changes.md when proposing a language change.

mdlayher commented 4 years ago

Please keep in mind the first point here: https://github.com/golang/proposal/blob/master/go2-language-changes.md#what-to-avoid

Your proposal simply changes syntax from X to Y because you prefer Y.

dmitryuck commented 4 years ago

Or add "->" operator

// write data to the channel "Hello world" -> c

// read data from channel var data := <- c

ianlancetaylor commented 4 years ago

For language change proposals, please fill out the template at https://go.googlesource.com/proposal/+/refs/heads/master/go2-language-changes.md .

When you are done, please reply to the issue with @gopherbot please remove label WaitingForInfo.

Thanks!

dmitryuck commented 4 years ago

For language change proposals, please fill out the template at https://go.googlesource.com/proposal/+/refs/heads/master/go2-language-changes.md .

When you are done, please reply to the issue with @gopherbot please remove label WaitingForInfo.

Thanks!

@gopherbot please remove label WaitingForInfo

ianlancetaylor commented 4 years ago

This seems to just be suggesting an alternate syntax for something that we can already do. It would add new keywords to the language, breaking existing code. The benefit is not worth the cost. Also the emoji voting is not in favor of this change.

Therefore, this is a likely decline. Leaving open for four weeks for final comments.

theohogberg commented 4 years ago

I don't personally agree with this!

The arrows in go have a direct historical link to unix, linux which are two most used OS:es for software/hardware nerds. They represented shorthands for reading/writing between files/programs as < and > symbols there.

If this had to be included the keyword should be "into" rather than "in" as it makes more sense. "in" is a keyword that can be used in javascript as a bool comparator for looking into objects, example: "sausage" in bread where "bread" is a js object.

It just adds confusion IMO, and if you like that type of confusion and ambiguity you should stick too the React & tc39 world

ianlancetaylor commented 4 years ago

No change in consensus.