|
|
|
|
|
by naikrovek
2561 days ago
|
|
It isn't purely functional, I don't think, but functions are a first-class thing in Go, aren't they? I mean, I've returned functions from functions, and passed functions as parameters.. and there's no requirement that a function modify state anywhere.. what else is required to be purely functional? |
|
"Purely functional" means that pure functions are not only possible, but that they are the only kinds of functions in the language.
While it might be theoretically possible to write purely functional code in Go, it doesn't have mechanisms for treating side effects as values, and the heavy reliance on arrays and channels and things would make it unnatural. Pure functions don't contain loops because a loop is only used to generate side effects. That would be hard in Go, but it's pleasant in languages that support pure FP.
If this explanation sounds weird, learn some Haskell to get an idea of what pure FP is like. It's fun stuff.