Difference between cmd/compile/internal/syntax/parser.go and pkg/go/parser/parser.go
140 views
Skip to first unread message
philne...@gmail.com
unread,
Mar 27, 2021, 8:07:38 PM3/27/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Hey folks,
Why does Go reimplement the parser in pkg/go/parser on top of the one in cmd/compile/internal? Why have two packages with somewhat duplicate code? My guess is that it's easier to control what is public-public (available to authors of Go programs) vs public within the compiler by having the partial duplicate two packages?
Happy for links if this question has been asked before.
Thank you!
Phil
aind...@gmail.com
unread,
Mar 27, 2021, 11:47:05 PM3/27/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
I won't speak for the maintainers of cmd/compile/internal/syntax, but packages in the standard library have to be backwards compatible with previous releases. This makes it difficult to make changes to its interface (possibly for performance reasons) and major re-architectures of its implementation (like coupling it with other parts of cmd/compile).
philne...@gmail.com
unread,
Mar 28, 2021, 4:30:47 PM3/28/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
The interesting thing furthermore is that it seems like the pkg/go/parser/parser.go has been around since Go 1.0 whereas the cmd/compile/internal was introduced in 1.6 when they translated the yacc parser to handwritten Go.