4 ms·
I don't think simply having a separate symbol table for packages and a separate one for types and variables would hurt much, and I hate writing things like aLis
by stiff 12y ago
I don't think simply having a separate symbol table for packages and a separate one for types and variables would hurt much, and I hate writing things like aList := list.New(). Having said this, I know many of those things are purported to have such and such super important reasons, it doesn't change the ugly "feel" of the end result. Another instance is the indication of visibility by case, they will go on and on about how it's a triumph of simplicity, I think it's simply an ugly notation.
- tptacek 12y agoI honestly am not sure I follow what your concern is with that line of code. list.New() looks extremely clean to me.
- stiff 12y agoYou frequently have packages that are named after generic nouns, like time, host, file etc. There are many contexts where this same generic name makes for the best variable name: clear, short, and easy to type: func ReadFile(filename String) { file := file.Open(filename) } In Go you have to invent a new name, so invariably you will see a lot of: theFile := file.Open(filename) aFile := file.Open(filename) readFile := file.Open(filename) depending on who wrote the code.
- tomp 12y agoUnless you're also frustrated by not being able to write `int int = 3` in C/C++/C#/Java/most other languages, I don't see the point of your concern. f = file.open("a.txt") out_file = file.open("b.txt", file.WRITE)
- Locke1689 12y agoIn the C# language we refer to this as the 'Color Color problem'. You have some enum or type Color and then a member of an object which you, quite obviously, want to name 'Color'. It's so annoying for the programmer to work around this that we define special exceptions in naming rules so the programmer can do what they want.
- dvirsky 12y agothe only place where I constantly find this annoying is the url package. url := oh wait, shit, already imported that. a couple of times I just changed the name of the import, as you sometimes do in Python: import ( urllib "net/url" ) url := urllib.QueryEscape(...) tada!
- monkey26 12y agoI've hit this a few times in Python and it bugged me like crazy. But then I grew up and dealt with it.