Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typo in lambda discussion #41

Open
zolia opened this issue Mar 24, 2021 · 1 comment
Open

typo in lambda discussion #41

zolia opened this issue Mar 24, 2021 · 1 comment

Comments

@zolia
Copy link

zolia commented Mar 24, 2021

func main() {
  ...
  datastore.Do(compare(data))
  ...
}

should be:

func main() {
  ...
  datastore.Do(concat(data))
  ...
}

I usually discourage the use of lambdas, but where are some situations when they really improve convenience for developers like time.AfterFunc(duration int, func()) or registering various handlers like: ch.Handle(conn.TopicInit, func(c conn.Context) error or famous type HandlerFunc func(ResponseWriter, *Request)

Lambas impairs the readability and traceability of a code in many cases, especially if the codebase is complex. IDEs also usually having trouble handling them properly, thus it might be hard to trace where certain lambda function originates from.

@Pungyeon
Copy link
Owner

Thanks for pointing out the error @zolia 🙇 I definitely agree. I think a lot of the time, the Go lambda is a crutch used for trying to deal with the lack of generics. I would also prefer avoiding them as much as possible, to be honest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants