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

2023-04-24 Thread Robert Engels
If you use Go’s “accept interfaces return concrete types” the dev/ide knows to declare the concrete type. Type inference can actually cause more issues during refactorings - not alleviate them. Personally, I find types make the code easier to read. But when I write ago I don’t use them. I fi

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

2023-04-24 Thread a2800276
import “os” func main() { file, _ := os.Open(os.Args[1]) myfunc(file) } func myfunc(file ???) { } What type should I use to declare “file” in the parameter list for myfunc()? This argument doesn't seem logical to me. If I fully declare `file` in this case, I also have to know whi

[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

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

2023-04-22 Thread peter so
I disagree. I don't have your problem. Most (just about all) Go code I read uses short variable declarations. There are several popular assistive technologies that you should try. For example, Visual Studio Code https://code.visualstudio.com/ GoLand https://www.jetbrains.com/go/ peter