by chimeracoder · 13y ago · 0 comments
Coming from a background in Lisp, I don't find much in Go that seems very 'elegant' or 'beautiful'. What I find is that everything - including the Go source code itself - is perfectly standardized (and therefore immediately readable).
I don't have to worry about different coding styles, about semicolons vs. no semicolons[0], about having more than one way to express the same code. I can skim the code easily because the structure is so uniform across all standard and community libraries.
That's a different kind of beauty from chaining macros and cons cells, but it's beautiful nonetheless.
Which, btw, gofmt does does pattern replacement.
http://talks.godoc.org/github.com/sunfmin/talks/2013/gofmt.s...
Slide 5 is the proof this is no better than search and replace.
This is a much better example: http://research.swtch.com/gofmt
gofmt -w -r 'x[i:len(x)] -> x[i:]' *.go
Note that this is not a regular expression... it's looking for go expressions that match that pattern.
So, for example, this will catch this:
a := charts[start:len(charts)]
and convert it to this:
a := charts[start:]
Combined with structural regular expressions you can answer questions like "what are the types that contain both a mutex and a map, and what are the types that contain the types that use a map without a mutex": http://pastebin.ca/2202690