design question: lexer in goroutine?
Open
- Dominant language
- Go
- Stars
- 198
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Description
While looking through the code, I noticed that the lexer runs its main loop its own goroutine:
```go
func lex(input string) (*lexer, error) {
...
l := &lexer{
input: input,
items: make(chan item),
}
go l.run()
return l, nil
}
```
Items are then received from the unbuffered channel `l.items` , thus making the code run fully sequential again.
Is there any other good reason to run it in it's own goroutine? If not, the overhead for synchronization and context switches could be avoided.
Contributor guide
Assessment
This issue has not been assessed yet.